Crashlytics not uploading mapping file

2020-02-06 11:45发布

问题:

I'm able to see crashes for a release build in Crashlytics but they are still obfuscated. I'm using:

implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.crashlytics.sdk.android:crashlytics:2.9.6"

and (project level)

    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.2.0'
    classpath 'io.fabric.tools:gradle:1.26.1' // Crashlytics plugin
    classpath "net.ltgt.gradle:gradle-apt-plugin:0.15"

I've followed the instructions at https://firebase.google.com/docs/crashlytics/get-deobfuscated-report, in particular I've deleted the -printmapping <path>/mapping.txt line from config.txt

When I look in the Crashlytics log I do not see an upload of the mapping file.

When I run a release build for an earlier version of my project using:

implementation "com.google.firebase:firebase-core:11.8.0"
implementation "com.google.android.gms:play-services-base:11.8.0"
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
    transitive = true
}

and (project level)

    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.google.gms:google-services:3.0.0'
    classpath 'io.fabric.tools:gradle:1.24.4'

then I see unobfuscated stack traces and mapping upload messages in crashlytics.log:

2018-11-21 10:52:22.573 [DEBUG] (Daemon worker) com.crashlytics  - Deobfuscation file(s) uploaded.

Any ideas what's wrong? I don't see any of the mapping file related logs for the recent (not working) version in the Crashlytics log and I don't see the gradle upload task running in the gradle output whereas for the older (working) version I see the following:

:app:crashlyticsUploadDeobsRelease (Thread[Daemon worker Thread 2,5,main]) completed. Took 1.28 secs.

回答1:

Argh. Well there was a simple fix, shame it took me so long to find it. I always (until now) build and locally install a release build using ./gradlew iR (shortcut for ./gradlew installRelease). I tried (after an embarrassingly long time) building from Android Studio instead (Build > Generate Signed Bundle / Apk). As soon as I did that it worked.

I'll update here if and when I figure out non-AS based releasing works with Crashlytics. Meanwhile if you're having problems take a look at the sample https://github.com/firebase/quickstart-android/tree/master/crash. You can take that, drop in your own google-services.json and release as above, then check crashlytics.log (see above) .



回答2:

Have you read here: https://docs.fabric.io/android/crashlytics/dex-and-proguard.html ?

I'm using those lines in my proguard-rules.pro file (inside your app folder) to get de-obfuscated crash reports

-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
# prevent Crashlytics obfuscation
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

And be sure to not have this line in your proguard file

-printmapping mapping.txt