Firebase Crashlytics - java.lang.IllegalStateException: The Crashlytics build ID is missing
Asked Answered
I

14

72

As per new version of Firebase Crashlytics added in Our App and application stopped at launch time.

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.

App-Level Gradle apply plugin: 'com.google.firebase.crashlytics'

implementation 'com.google.firebase:firebase-crashlytics:17.1.1'

Project-Levle Gradle classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'

Follow steps by step from Firebase guides Firebase Guides

But earlier Fabric version is too much better than current one.

Any help will be appreciated.

Impatience answered 9/8, 2020 at 10:57 Comment(2)
Having the same issue. Will post solution here once I figure it outChemist
This bug is annoying. We have it and I have done everything to help fixing it but no luckCamerlengo
P
78

In the build.gradle at the application level, add the following imports
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

Then, in the gradle/wrapper/gradle-wrapper.properties file, upgrade your gradle version to 5.6.4
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

I used to run my app with gradle 5.1.1 and upgrading to the version 5.6.4 fixed my problems

I hope it'll help you !

Prescott answered 8/9, 2020 at 13:52 Comment(4)
Thanks, this helped to resolve the issue. I've checked at services.gradle.org/distributions that 5.6.4 is the most recent version 5.Gibran
This is why google document sucks. There is no mention of this. Wasted 1 hr trying to add the id somehow by updating google-services.json and what not.Wertheimer
Also remember to include the buildscript dependencies classpath in the root build.gradle as mentioned by Amir RazaWertheimer
I am trying to remove crashlytics since my team is migrating to Sentry. When i removed all references to Crashlytics i am getting this error E/FirebaseCrashlytics: 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. how do i resolve this?Sarraceniaceous
D
32

That normally happens when the plugin apply plugin: 'com.google.firebase.crashlytics' is missing in build.gradle app level.

Durbar answered 17/11, 2020 at 18:14 Comment(1)
no it's not. please don't make it an exact answerTrabeated
G
24

If anyone still have problem with this issue, try using crashlytics gradle verions 2.1.1 in project level gradle. I solved my problem by doing so.

buildscript {       
    ...
    dependencies {
        ... 
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'    
    }
}
Gusty answered 4/11, 2020 at 11:19 Comment(1)
While indeed downgrading this from 2.4.1 to 2.1.1 (or even 2.2.1) resolved the issue, it's probably a better option to update the cradle version in the gradle/wrapper/gradle-wrapper.properties file, as instructed by xerib: https://mcmap.net/q/273313/-firebase-crashlytics-java-lang-illegalstateexception-the-crashlytics-build-id-is-missingGibran
S
23

please add

 classpath 'com.google.firebase:firebase-crashlytics-gradle:x.x.x'

to your project's build gradle. And don't forget to add following lines to your app's build gradle

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
}
Szabo answered 3/5, 2021 at 8:21 Comment(0)
C
12

It will also happen if you forgot to include classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1' in your project level build.gradle

buildscript {
    repositories {
        // Check that you have Google's Maven repository (if not, add it).
        google()
    }

    dependencies {
        // ...

        // Check that you have the Google services Gradle plugin v4.3.2 or later
        // (if not, add it).
        classpath 'com.google.gms:google-services:4.3.8'

        // Add the Crashlytics Gradle plugin
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
    }
}

allprojects {
    repositories {
        // Check that you have Google's Maven repository (if not, add it).
        google()
    }
}
Cultivated answered 10/7, 2021 at 7:9 Comment(0)
U
5

The only thing that solved my problem was to add the following line - <string name="com.crashlytics.android.build_id">1</string> to strings.xml, as suggested here.

Upcountry answered 8/2, 2023 at 10:38 Comment(0)
R
4

Add the code below to project/android/app/build.gradle

apply plugin: 'com.google.firebase.crashlytics'

Rita answered 5/10, 2022 at 12:17 Comment(0)
L
4

In my case this error is caused by shrinkResources = true (in app/build.gradle) in combination with android-gradle-plugin version 8.3.0-alphaXX.

In order to fix this I had to add a keep.xml file under res/raw/keep.xml with the following input:

<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@string/com.google.firebase.crashlytics.*" />

The actual reason why this bug was introduced by R8 and firebase can be found here: https://github.com/firebase/firebase-android-sdk/issues/5562#issuecomment-1825591774

Lend answered 1/12, 2023 at 13:49 Comment(0)
T
1

add this line

implementation "com.google.firebase:firebase-iid"

this will solve this problem

Thanh answered 24/6, 2021 at 9:25 Comment(1)
Don't see such a plugin listed @ firebase.google.com/docs/android/setup#available-libraries almost thought this wouldn't work.Arliearliene
D
0

After several hours i finally figured it out. I used ./gradlew app:dependencies command to list the dependency tree just to notice, that some libraries (that were not up to date) used older version of crashlytics library. I updated them and the issue was finally gone!

Disaccredit answered 21/8, 2023 at 18:19 Comment(0)
E
0

I also struggle with this crash (just in my release builds) and as a temporary fix it helps me to turn off shrinking resources. TBH don't know the reason why it was causing this crash yet 🙃

So you can try to set isShrinkResources = false in your app/build.gradle.kts file if you have it enabled

Eris answered 8/11, 2023 at 14:19 Comment(0)
R
0

This solution from google documentation:

Gradle file (project-level)

buildscript {

    repositories {
      // Make sure that you have the following two repositories
      google()  // Google's Maven repository
      mavenCentral()  // Maven Central repository
    }

    dependencies {
      ...

      // add this line
      classpath ("com.google.firebase:firebase-crashlytics-gradle :2.9.9")
    }
}

allprojects {
  ...

  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository
    mavenCentral()  // Maven Central repository
  }
}

module (app-level) Gradle file

plugins {
    id("com.android.application")

    // Add the ID of the plugin
    id("com.google.firebase.crashlytics")
    ...
}
Riotous answered 18/12, 2023 at 21:7 Comment(0)
T
0

For those who added the classpath but still ran into the exception, make sure that there isn't a space between the colon and the version number, oddly it'll still crash.

Crash:

classpath 'com.google.firebase:firebase-crashlytics-gradle: 2.9.9' // look at the space in between the colon and 2.9.9

No Crash:

classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9' // no space in between the colon and 2.9.9
Testamentary answered 8/4, 2024 at 1:6 Comment(2)
This worked for me . No Space in between the colon and version will solve the crash issue.Menace
@KiranSrinivasRao, hi, if it worked please upvote this answer so others can see it worksTestamentary
S
0
Step 1) In your build.gradle.kts file (Project) to past this line
plugins {

id ("com.google.gms.google-services") version "4.3.15" apply false
id ("com.google.firebase.crashlytics") version "2.9.1" apply false

}

Step 2) In your build,gradle.kts(App) to past this line



 plugins {
   
         id("com.google.gms.google-services")
        id("com.google.firebase.crashlytics")
    }

dependencies {
   implementation("com.google.firebase:firebase-analytics-ktx:21.6.2")
    implementation("com.google.firebase:firebase-crashlytics-ktx:18.6.4")
    implementation("com.google.firebase:firebase-perf:20.5.2")
}
Serieswound answered 23/4, 2024 at 7:30 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.