Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crashlytics' stacktraces show file name as Unknown Source while Dexguard is enabled

I've got a problem with my crash reports from Fabric Crashlytics when I enable Dexguard in my project.

I enabled Dexguard in my project and it works pretty well. Then I followed the instructions in this this page and added the mentioned configurations to enable fabric de-obfuscate my stacktraces and show proper crash reports. Here's how I apply fabric and dexguard plugins in my main module's build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'dexguard'
apply plugin: 'io.fabric'

And here are the configurations in my proguard-project.txt file:

# Fabric
#############################################################################
-keepattributes *Annotation*,SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keepresourcexmlelements manifest/application/meta-data@name=io.fabric.ApiKey
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
#############################################################################

And here's how I use proguard-project.txt in my release build:

buildTypes{
    debug{
        proguardFile getDefaultDexGuardFile('dexguard-debug-shrink.pro')
        proguardFile 'proguard-project.txt'
    }
    release{
        proguardFile getDefaultDexGuardFile('dexguard-release.pro')
        proguardFile 'proguard-project.txt'
        proguardFile 'dexguard-project.txt'
        if(new File("$projectDir/../local.properties").exists()){
            signingConfig signingConfigs.release
        }
    }
}

But when a crash is encountered in the release build the file name in which the crash has occurred is missing, but everything else is working correctly and the stacktrace is almost understandable. Here's a sample crash report:

Unknown source file names

As you can see in the crash report, only the file name is missing in the stacktrace. The other descriptions like line numbers and method names are completely OK.

Although using the complete method names like ir.X.ui.XMainActivity.throwSomething and the line numbers in front of the Unknown Source, I can conclude the file name in which the error has occured, I'd like my stacktraces to show the file names and be completely descriptive themeselves. I've tried many options and many trials and errors but the problem still exists.

Is there anything I'm missing? How can I solve this problem?

I'm using version 8.1.0.7 of Dexguard, version 1.21.7 of Fabric plugin and version 2.9.0 of Crashlytics library.

I updated the Fabric plugin to version 1.25.1 and the Crashlytics library to version 2.9.1 but the problem still exists.

I updated the Fabric plugin to version 1.25.2, build tools version to 27.0.3, and gradle plugin version to 3.1.0 but the problem still exists.

like image 940
Amin Avatar asked Mar 12 '18 09:03

Amin


People also ask

What about Crashlytics and nsexceptions?

What about NSExceptions? What about NSExceptions? This guide describes how to customize your crash reports using the Firebase Crashlytics SDK. By default, Crashlytics automatically collects crash reports for all your app's users (you can turn off automatic crash reporting and enable opt-in reporting for your users instead).

How do I disable Crashlytics crash reporting in the SDK?

If your project uses Crashlytics alongside the Google Mobile Ads SDK, it's likely that the crash reporters are interfering when registering exception handlers. To fix the issue, turn off crash reporting in the Mobile Ads SDK by calling disableSDKCrashReporting.

Does Crashlytics store crash data on the device?

Note: When data collection is disabled, Crashlytics will store crash information locally on the device. If data collection is subsequently enabled, any crash information stored on the device will be sent to Crashlytics for processing.

How does Crashlytics handle nserror logs?

Because Crashlytics only sends the logged error report on the next app launch and must limit the amount of space allocated for logs on disk, it is possible to log enough after an NSError is recorded so that all relevant logs are rotated out by the time Crashlytics sends the report from the device.


3 Answers

You can take following steps for deobfuscated crash reports. As quoted from firebase crashlytics documentation

 1. To preserve the info Crashlytics needs for readable crash reports, add the following lines to your config file:

 -keepattributes *Annotation*
 -keepattributes SourceFile,LineNumberTable
 -keep public class * extends java.lang.Exception

  2. To let Crashlytics automatically upload the ProGuard or DexGuard mapping file, remove this line from the config file:

 -printmapping mapping.txt
like image 160
Honey Shah Avatar answered Sep 30 '22 10:09

Honey Shah


Dexguard encrypt the code and obfuscated the files and crash reports

According to Question, Everything defined correctly which enables crash reports, Nothing to change. In My Project Scenario also same, using Dexguard With Fabric.

When integrating Dexguard in Project, Dexguard encrypt the code and obfuscated the files and crash reports for other libraries.

How ever, if you're using google Firebase Crashlytics also, you can't able to see the log in Firebase Console. You will get the Same Report which Fabric provided.

These Crashlytics will provide the crash reports in Google Console. you check the crash log's in ANR & Crashes Section in Android Vitals.

That section shows all ANRs & crashes collected from Android devices whose users have opted in to automatically share usage and diagnostics data. Anomalies can only be detected for non-obfuscated stack traces.

Google Explained about this section https://support.google.com/googleplay/android-developer/answer/6083203

like image 26
Keerthivasan Avatar answered Sep 30 '22 12:09

Keerthivasan


Follow the below steps to get the stack traces properly in Crashlytics

  1. Sign in to your Play Console.
  2. Select an app.
  3. On the left menu, click Android vitals > Deobfuscation files.
  4. Next to a version of your app, click Upload.
  5. Upload the ProGuard mapping file for the version of your app.

Check this link: https://support.google.com/googleplay/android-developer/answer/6295281?hl=en

like image 33
Avijit Karmakar Avatar answered Sep 30 '22 10:09

Avijit Karmakar