quickstart-android icon indicating copy to clipboard operation
quickstart-android copied to clipboard

How to get crashlytics stacktraces deobfuscated

Open GuanacoDevs opened this issue 7 years ago • 23 comments

Step 1: Describe your environment

  • Android device: Any
  • Android OS version: Any
  • Google Play Services version: 4.2.0
  • Firebase/Play Services SDK version: 17.0.0

Step 2: Describe the problem:

Ever since Google introduced R8 I'm not getting my crashes stacktraces in crashlytics deobfuscated. I used to get them before, but not anymore, have the configuration described in this page. What should I do to get my crashlytics crashes report deobfuscated, the Stack Traces from Google Play are deobfuscated.

Relevant Code:

proguard-rules.pro

-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

GuanacoDevs avatar Jun 22 '19 02:06 GuanacoDevs

@GuanacoDevs are you using the plugin to upload the R8 mapping file to Crashlytics?

You need to use 1.28.0 or higher to get R8 to work: https://docs.fabric.io/android/changelog.html#march-15-2019

samtstern avatar Jun 25 '19 20:06 samtstern

Yes

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.28.0'
    }
}

and in app:

dependencies {
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}  

GuanacoDevs avatar Jun 25 '19 21:06 GuanacoDevs

Do you see any errors in the logs? They would be in this file:

On Linux / Windows:

/.crashlytics/com.crashlytics.tools/crashlytics.log

On Mac:

~/Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log

samtstern avatar Jun 26 '19 18:06 samtstern

There is an error but from dec '18. I have saved the logs from what I think is the last production release that I have uploaded and published here if you get the chance to take a look at it. This is how a crash looks on the Console: screenshot_full Can't seem to find the same crash in Play Console, but another crash looks deobfuscated. I'm using linux mint.

The full app build.gradle is:

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

android {
    compileSdkVersion 29
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "com.guanacodevs.ubv"
        minSdkVersion 21
        targetSdkVersion 29
        //noinspection HighAppVersionCode
        versionCode 2019062202
        versionName "Iñaki 2.5.5"
        resConfigs "en", "pt", "es"
        vectorDrawables.generatedDensities = []
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
//    
    implementation 'com.android.billingclient:billing:1.2.2'
//
    implementation 'com.google.android.ads.consent:consent-library:1.0.7'
    implementation 'com.google.android.material:material:1.0.0'
//
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'com.google.firebase:firebase-ml-vision:21.0.0'
    implementation 'com.google.firebase:firebase-ads:18.0.0'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
//
    implementation 'com.otaliastudios:cameraview:2.0.0-beta04'
    implementation 'com.google.code.gson:gson:2.8.5'
//
    testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

and the project build.gradle:

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.28.0'
    }
}

allprojects {
//    tasks.withType(JavaCompile) {
//        options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
//    }
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Thank you for your time @samtstern

GuanacoDevs avatar Jun 26 '19 19:06 GuanacoDevs

Hmmm I do see things in the logs that indicate the deobfuscation file should have been uploaded:

2019-06-22 02:48:34.987 [DEBUG] (Execution worker for ':' Thread 3) com.crashlytics  - Uploading deobfuscation file
2019-06-22 02:48:34.992 [DEBUG] (Execution worker for ':' Thread 3) com.crashlytics  - POST file: /home/racu/.crashlytics/com.crashlytics.tools/********************************************/deobs/db4bad94-d95e-4624-9124-a0dde6d753cc.zip to URL: https://cm.crashlytics.com/api/v3/platforms/android/code_mappings
2019-06-22 02:48:41.318 [DEBUG] (Execution worker for ':' Thread 3) com.crashlytics  - POST response: [reqId=f62395bf6f551a20bc6a64fe49c1ef9f9229a2c3a6e98ed8] 202
2019-06-22 02:48:41.319 [DEBUG] (Execution worker for ':' Thread 3) com.crashlytics  - Deobfuscation file(s) uploaded.
2019-06-22 02:49:48.581 [DEBUG] (Execution worker for ':' Thread 2) com.crashlytics  - Invoked Crashlytics Developer Tools with arguments: 

So I am not sure what's going on. I will have to ask around.

samtstern avatar Jun 27 '19 17:06 samtstern

I have added to my application tag in the manifest

        <meta-data
            android:name="firebase_crashlytics_collection_enabled"
            android:value="true" />

and removed from my Application class were used to initialize Crashlitycs, but I still can't get stack traces deobfucated.

    private void configureCrashReporting() {
        CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder()
                .disabled(BuildConfig.DEBUG)
                .build();
        Fabric.with(this, new Crashlytics.Builder().core(crashlyticsCore).build());
    }

GuanacoDevs avatar Jul 29 '19 22:07 GuanacoDevs

@GuanacoDevs had the same issue after updating to 'io.fabric.tools:gradle:1.31.0' crash reports are deobfuscated properly

AndroidGecko avatar Aug 03 '19 19:08 AndroidGecko

@AndroidGecko Thank you, I'll try that and close this issue. If I still can't get deobfuscated stack traces I'll reopen.

GuanacoDevs avatar Aug 04 '19 21:08 GuanacoDevs

Updating to io.fabric.tools:gradle:1.31.0 did not work, still can't get the stack traces deobfuscated, this is really painful. What am I missing here?

GuanacoDevs avatar Aug 17 '19 18:08 GuanacoDevs

Same problem.

jeminay avatar Sep 11 '19 13:09 jeminay

same problem

ghost avatar Oct 06 '19 21:10 ghost

also seeing the same issue after migrating to R8

ouchadam avatar Oct 09 '19 13:10 ouchadam

While build your application to be release look for this task > "crashlyticsUploadDeobs" and check if it's executed correctly or not

you can also find more logs under Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log

oahmedazab avatar Nov 18 '19 15:11 oahmedazab

I couldn't find the file crashlytics.log anywhere on my computer

ghost avatar Nov 18 '19 15:11 ghost

i updated fabric plugin to io.fabric.tools:gradle:1.31.0 and its working now

oahmedazab avatar Nov 24 '19 13:11 oahmedazab

To add to oahmedazab's comment, you can specifically run:

./gradlew clean assembleDebug --console=plain

and see if the task "crashlyticsUploadDeobsDebug" appears.

You should be able to find the crashlytics.log in that path and that will tell you if the mapping file is getting successfully uploaded or not, but if that doesn't work, these are all possible paths:

Windows/Linux: ~/.crashlytics/com.crashlytics.tools/crashlytics.log ~/.crashlytics/com.crashlytics.tools.androidstudio/logs/crashlytics.log ~/.crashlytics/com.crashlytics.tools.intellij/logs/crashlytics.log

Mac: ~/Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log ~/Library/Caches/com.crashlytics/com.crashlytics.tools.androidstudio/logs/crashlytics.log ~/Library/Caches/com.crashlytics/com.crashlytics.tools.intellij/logs/crashlytics.log

We're not yet able to reproduce this problem, but it's interesting that for some people upgrading to Fabric Gradle plugin 1.31.0 helps but not for others. @oahmedazab are you able to observe any difference in the crashlytics.log between builds before upgrading and for builds after?

kevinkokomani avatar Nov 27 '19 20:11 kevinkokomani

I get the same problem with io.fabric.tools:gradle:1.31.2. Logs show that Deobfuscation file(s) uploaded, but stack traces in Crashlytics are obfuscated, for example b.a.a.a.s0.m.j1.l.

Vlad-M-1 avatar Dec 04 '19 22:12 Vlad-M-1

That was my mistake. I've looked into exception description, not stack trace. Stack trace is fine. Sorry.

Vlad-M-1 avatar Dec 05 '19 17:12 Vlad-M-1

We were struggling with this issue as well - thought bumping to 1.30+ would be the solution (per https://github.com/firebase/firebase-android-sdk/issues/745). What we ended up finding was that we were losing the deobfuscation only when distributing the apk through Firebase, and only when doing so via the appDistributionUploadRelease gradle command. (Manual APK uploads to Firebase were fine). In our case, we were running ./gradlew appDistributionUploadRelease after running ./gradlew assembleRelease both on their own. We realized the appDistributionUploadRelease task didn't call crashlyticsUploadDeobsRelease, and thus realized we should have been calling ./gradlew assembleRelease appDistributionUploadRelease as a single command. (As the docs state, sheesh!) Hopefully that will help someone some headache in the future (or help y'all potentially repro the issue :) )

poko avatar Dec 18 '19 21:12 poko

Thanks all for the continued reports and information on R8 + Crashlytics. Has anyone tried this with Android Gradle plugin version 3.5.3 and can report back what the behavior is when using that version? We believe we've seen some improved behavior when using that version of AGP, but would like to confirm if there are any reports of this behavior in other setups.

kevinkokomani avatar Jan 21 '20 17:01 kevinkokomani