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

3

20

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.

Adham answered 12/3, 2018 at 9:41 Comment(8)
Mike from Fabric here. Thanks for the well documented question. One thing I notice is that you're using 1.21.7 of our Gradle plugin which is very old. Try updating to 1.25.1 and let me know if that changes anything.Advisable
Thanks Mike, I updated the gradle plugin to version 1.25.1 and the Crashlytics library to 2.9.1 but it's still problematic. It's even more weird, the first line shows: ir.resid.ui.ResidMainActivity.throwSomething (Unknown Source:87469)Adham
Note that the issue starts with XposedBridge - that is part of the Xposed framework (basically a Malware Framework) which extends components and hooks into events. The main use I've seen for it is making In-App purchases free or cheating at games. It's down to your own opinion, but in my experience it causes a lot of crash reports for many apps which don't really require fixing if used on an uninfected device.Russelrussell
The problem is not the crash reports, it's the 'Unknown Source' part that comes instead of the class names in stacktraces and it's visible in the pictures inlined in the question.Adham
Any luck @MohamadAmin? This is affecting one of my projects with a seemingly identical configuration to another project which is working... It's honestly driving me nuts that something so inane can be blocking a release.Clapboard
Nothing @damien-diehl, seems one of Dexguard or Crashlytics 's fault to me, not our configuration.Adham
Please don't post images of code.Riobard
Unknown Source is where the file name would be (e.g. Something.java:608). You don't need that. The class name (ResidMainActivity) and method name (throwSomething) have resolved correctly and from that you can guess the file name or have the IDE find the class for you. This is OK.Duelist
T
10

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
Thanksgiving answered 17/4, 2018 at 6:33 Comment(2)
Thanks, but as I explained in my question, I have done both of these from the beginning and the result is as it's shown in the question.Adham
@HoneyShah can you explain me point number 2, please? Where does it automatically uploads the mapping file?Walterwalters
S
4

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

Stairs answered 14/7, 2018 at 5:51 Comment(0)
T
4

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

Twist answered 14/7, 2018 at 14:58 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.