android – Crashlytics' stacktraces show file name as Unknown Source while Dexguard is enabled-ThrowExceptions

Exception or error:

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.

How to solve:

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

###

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

###

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

Leave a Reply

Your email address will not be published. Required fields are marked *