Pratik Dodiya
Pratik Dodiya

Reputation: 2667

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

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.

Upvotes: 76

Views: 64952

Answers (15)

Jcorretjer
Jcorretjer

Reputation: 497

In my case, the problem was present only on release builds due to R8 being set to "strict". If you're having similar issues with release builds and have R8 enabled, I suggest you add the following entry to your keep.xml file

@string/com_google_firebase_crashlytics_*

In the end should look something like this:

<resources
    xmlns:tools="http://schemas.android.com/tools"
    tools:shrinkMode="strict"
    tools:keep="@string/com_google_firebase_crashlytics_*"/>

Upvotes: 0

Gaurav Meghanathi
Gaurav Meghanathi

Reputation: 1

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")
}

Upvotes: 0

Lance Samaria
Lance Samaria

Reputation: 19572

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

Upvotes: -1

Ahmed Saad
Ahmed Saad

Reputation: 175

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")
    ...
}

Upvotes: 0

goemic
goemic

Reputation: 1339

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

Upvotes: 4

west44
west44

Reputation: 749

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

Upvotes: 0

Michal Neubauer
Michal Neubauer

Reputation: 69

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!

Upvotes: 0

TDG
TDG

Reputation: 6151

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.

Upvotes: 7

Chinedu Ofor
Chinedu Ofor

Reputation: 767

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

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

Upvotes: 6

flamyoad
flamyoad

Reputation: 565

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()
    }
}

Upvotes: 12

Alhaj
Alhaj

Reputation: 19

add this line

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

this will solve this problem

Upvotes: 1

Lahiru Prasanna
Lahiru Prasanna

Reputation: 1092

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'
}

Upvotes: 24

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

Upvotes: 33

Amir Raza
Amir Raza

Reputation: 2860

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'    
    }
}

Upvotes: 25

FDuhen
FDuhen

Reputation: 4826

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 !

Upvotes: 81

Related Questions