Firebase-android-sdk: Crashlytics setup crashes app on every second run

Created on 23 Jul 2020  路  9Comments  路  Source: firebase/firebase-android-sdk

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in __the code in this repository__.
If you have a general question, need help debugging, or fall into some
other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 3.4.2
  • Firebase Component: Crashlytics
  • Component version: 17.1.1
  • Crashlytics Gradle plugin version: 2.2.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

On every second start of the app, it crashes during startup with the following error:

 java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.IllegalStateException: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.
        at android.app.ActivityThread.installProvider(ActivityThread.java:5265)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4847)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4787)
        at android.app.ActivityThread.access$1600(ActivityThread.java:154)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1452)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:234)
        at android.app.ActivityThread.main(ActivityThread.java:5526)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.IllegalStateException: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.
        at com.google.firebase.crashlytics.internal.common.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:122)
        at com.google.firebase.crashlytics.FirebaseCrashlytics.init(FirebaseCrashlytics.java:165)
        at com.google.firebase.crashlytics.CrashlyticsRegistrar.buildCrashlytics(CrashlyticsRegistrar.java:55)
        at com.google.firebase.crashlytics.CrashlyticsRegistrar.access$lambda$0(CrashlyticsRegistrar.java)
        at com.google.firebase.crashlytics.CrashlyticsRegistrar$$Lambda$1.create(CrashlyticsRegistrar.java)
        at com.google.firebase.components.ComponentRuntime.lambda$new$0(com.google.firebase:firebase-components@@16.0.0:69)
        at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(com.google.firebase:firebase-components@@16.0.0)
        at com.google.firebase.components.Lazy.get(com.google.firebase:firebase-components@@16.0.0:53)
        at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(com.google.firebase:firebase-components@@16.0.0:158)
        at com.google.firebase.FirebaseApp.initializeAllApis(com.google.firebase:firebase-common@@19.3.0:563)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:304)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:268)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:253)
        at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@19.3.0:51)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)

It seems to be a crashlytics gradle plugin issue, as it deletes com_crashlytics_build_id.xml in build\generated\crashlytics on every second run, thus causing the crash. It works with gradle plugin 2.1.1

Relevant Code:

Project level build.gradle excerpt:

classpath 'com.android.tools.build:gradle:3.4.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'

Module level build.gradle excerpt:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "com.appid"
        minSdkVersion 21
        targetSdkVersion 28
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
        }
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-dynamic-links:17.0.0'
    implementation 'com.google.android.gms:play-services-ads:17.2.0'
    implementation 'com.google.firebase:firebase-crashlytics:17.1.1'
}

crashlytics

Most helpful comment

my team run into the same problem and we managed to workaround like this (to make the gradle always generate the file for us)

tasks.whenTaskAdded { task ->
        if (task.name.startsWith("injectCrashlyticsMappingFileId")) {
            task.outputs.upToDateWhen { false }
        }
    }

Hope we can know the root cause of this issue

All 9 comments

Hi there, thanks a lot for this report. "It seems to be a crashlytics gradle plugin issue, as it deletes com_crashlytics_build_id.xml in build\generated\crashlytics on every second run, thus causing the crash. It works with gradle plugin 2.1.1" looks especially interesting - let me look into this and see if we are able to reproduce it.

Hi @vegesm, sorry for the delay. I tried to reproduce this with the above steps and dependencies and wasn't able to produce this IllegalStateException. Would you be able to reach out to Firebase support, mention this GitHub issue, and produce a minimally viable reproducible example for support to verify?

my team run into the same problem and we managed to workaround like this (to make the gradle always generate the file for us)

tasks.whenTaskAdded { task ->
        if (task.name.startsWith("injectCrashlyticsMappingFileId")) {
            task.outputs.upToDateWhen { false }
        }
    }

Hope we can know the root cause of this issue

I encounter same problem.
But after i upgrade build gradle version to v4.0.1, the problem seems not happen again.

Thanks for the reports and workarounds everyone. I'm bringing this up with the team in case there's any action, but it sounds like being on more recent versions clears up the issue, which may be intended.

Same issue, use"crashlytics-gradle:2.1.1" work well on Android Studio4.0.1 in "build:gradle:3.4.1".

I have the same issue. After upgrading gradle to 5.6.4, it's resolved.

At first I use gradle 5.1.1, but it seems to not work with firebase-crashlytics-gradle 2.2.0.

I update the gradle-wrapper.properties like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

We also had this issue and we updated from Gradle 5.1.1 to 5.6.4 and the issue has now been resolved. Thank you @songzhangzhang .

Hi everyone, thanks for posting your solutions and workarounds. The eng team was unable to reproduce this error. Since it seems to only affect specific, older versions of the Android plugin & Gradle, we recommend updating or using the workaround described by @tsengvn (thank you for posting that here!).

Was this page helpful?
0 / 5 - 0 ratings