When I’m doing an incremental build in Android Studio, Firebase Crashlytics crashes with ‘The Crashlytics build ID is missing’

I am adding Firebase Crashlytics in my Android application. I carefully followed instructions in https://firebase.google.com/docs/crashlytics/get-started?platform=android.

When I rebuild and run the app (in Android Studio), everything is working well and I am able to receive crash reports.

BUT: When I make some changes in my code in Android Studio and re-run the app, it crashes with the following report.

07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .     |  |
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .     |  |
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .     |  |
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .    |  | /
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .        /
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .       /
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .      /
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .
07-25 17:30:40.916 24237 24237 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.
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .      /
07-25 17:30:40.916 24237 24237 E FirebaseCrashlytics: .     /  
07-25 17:30:40.917 24237 24237 E FirebaseCrashlytics: .    /    
07-25 17:30:40.917 24237 24237 E FirebaseCrashlytics: .   / |  | 
07-25 17:30:40.917 24237 24237 E FirebaseCrashlytics: .     |  |
07-25 17:30:40.917 24237 24237 E FirebaseCrashlytics: .     |  |
07-25 17:30:40.917 24237 24237 E FirebaseCrashlytics: .
07-25 17:30:40.918 24237 24237 E AndroidRuntime: 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.
07-25 17:30:40.918 24237 24237 E AndroidRuntime: 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.
07-25 17:30:40.918 24237 24237 E AndroidRuntime:        at com.google.firebase.crashlytics.internal.common.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:122)
07-25 17:30:40.918 24237 24237 E AndroidRuntime:        at com.google.firebase.crashlytics.FirebaseCrashlytics.init(FirebaseCrashlytics.java:165)
07-25 17:30:40.918 24237 24237 E AndroidRuntime:        at com.google.firebase.crashlytics.CrashlyticsRegistrar.buildCrashlytics(CrashlyticsRegistrar.java:55)
07-25 17:30:40.918 24237 24237 E AndroidRuntime:        at com.google.firebase.crashlytics.CrashlyticsRegistrar.access$lambda$0(Unknown Source:0)
07-25 17:30:40.918 24237 24237 E AndroidRuntime:        at com.google.firebase.crashlytics.CrashlyticsRegistrar$$Lambda$1.create(Unknown Source:2)

How to fix this? Does this behavior relate to the Firebase issue reported here? https://github.com/firebase/firebase-android-sdk/issues/1523

I’m using the following dependencies:

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

UPDATE: Gradle build logs for full and incremental builds.

Gradle log after full rebuild: contains parsing of google-services.json

Executing tasks: [clean, :app:assembleMasterRelease, :lib:assembleDebug] in project C:srchmdmandroid-kiosk


> Configure project :app
Copying common files to all enterprise build variants

> Task :clean
> Task :app:clean
> Task :lib:clean
> Task :app:copyFiles NO-SOURCE
> Task :app:preBuild UP-TO-DATE
> Task :app:injectCrashlyticsMappingFileIdMasterRelease
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:preMasterReleaseBuild
> Task :app:compileMasterReleaseAidl
> Task :app:compileMasterReleaseRenderscript NO-SOURCE
> Task :app:checkMasterReleaseManifest
> Task :app:generateMasterReleaseBuildConfig

> Task :app:processMasterReleaseGoogleServices
Parsing json file: C:srchmdmandroid-kioskappgoogle-services.json

> Task :app:generateMasterReleaseSources
> Task :app:dataBindingExportBuildInfoMasterRelease
> Task :app:dataBindingExportFeaturePackageIdsMasterRelease
> Task :app:dataBindingMergeDependencyArtifactsMasterRelease
> Task :app:dataBindingMergeGenClassesMasterRelease
> Task :app:generateMasterReleaseResValues
> Task :app:generateMasterReleaseResources
> Task :app:mergeMasterReleaseResources
> Task :app:dataBindingGenBaseClassesMasterRelease
> Task :app:javaPreCompileMasterRelease
> Task :app:mainApkListPersistenceMasterRelease
> Task :app:createMasterReleaseCompatibleScreenManifests
> Task :app:processMasterReleaseManifest
> Task :app:processMasterReleaseResources

> Task :app:compileMasterReleaseJavaWithJavac
Gradle may disable incremental compilation as the following annotation processors are not incremental: databinding-compiler-3.4.1.jar (androidx.databinding:databinding-compiler:3.4.1).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run annotation processing in a separate task and make compilation incremental.
warning: loading is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap loading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutactivity_main.xml Line:50
warning: downloading is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap downloading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutactivity_main.xml Line:63
warning: downloading is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap downloading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutactivity_main.xml Line:72
warning: showContent is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap showContent with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutactivity_main.xml Line:98
warning: error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_server.xml Line:41
warning: !error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap !error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_server.xml Line:47
warning: error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_password.xml Line:40
warning: !error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap !error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_password.xml Line:46
warning: loading is a boxed field but needs to be un-boxed to execute bind:boolToDisable. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap loading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_password.xml Line:52
warning: loading is a boxed field but needs to be un-boxed to execute bind:boolToDisable. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap loading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_password.xml Line:67
warning: error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_device_id.xml Line:40
warning: !error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap !error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_device_id.xml Line:47
warning: error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_device_id.xml Line:91
warning: downloadedLength is a boxed field but needs to be un-boxed to execute String.valueOf(downloadedLength). This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap downloadedLength with safeUnbox() to prevent the warning
warning: fileLength is a boxed field but needs to be un-boxed to execute String.valueOf(fileLength). This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap fileLength with safeUnbox() to prevent the warning
warning: error is a boxed field but needs to be un-boxed to execute !error. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
warning: error is a boxed field but needs to be un-boxed to execute !error. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
warning: error is a boxed field but needs to be un-boxed to execute !error. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
18 warnings

> Task :app:compileMasterReleaseSources
> Task :app:mergeMasterReleaseShaders
> Task :app:lintVitalMasterRelease
> Task :app:compileMasterReleaseShaders
> Task :app:generateMasterReleaseAssets
> Task :app:mergeMasterReleaseAssets
> Task :app:validateSigningMasterRelease
> Task :app:signingConfigWriterMasterRelease
> Task :app:checkMasterReleaseDuplicateClasses
> Task :app:transformClassesWithDexBuilderForMasterRelease
> Task :app:transformClassesWithMultidexlistForMasterRelease
> Task :app:transformDexArchiveWithDexMergerForMasterRelease
> Task :app:mergeMasterReleaseJniLibFolders
> Task :app:transformNativeLibsWithMergeJniLibsForMasterRelease
> Task :app:processMasterReleaseJavaRes NO-SOURCE
> Task :app:transformResourcesWithMergeJavaResForMasterRelease
> Task :app:packageMasterRelease
> Task :app:assembleMasterRelease
> Task :lib:preBuild UP-TO-DATE
> Task :lib:preDebugBuild UP-TO-DATE
> Task :lib:checkDebugManifest
> Task :lib:generateDebugBuildConfig
> Task :lib:generateDebugResValues
> Task :lib:processDebugManifest
> Task :lib:prepareLintJar
> Task :lib:mergeDebugConsumerProguardFiles
> Task :lib:mergeDebugShaders
> Task :lib:compileDebugShaders
> Task :lib:generateDebugAssets
> Task :lib:packageDebugAssets
> Task :lib:packageDebugRenderscript NO-SOURCE
> Task :lib:prepareLintJarForPublish
> Task :lib:compileDebugAidl
> Task :lib:compileDebugRenderscript NO-SOURCE
> Task :lib:generateDebugResources
> Task :lib:packageDebugResources
> Task :lib:generateDebugRFile
> Task :lib:generateDebugSources
> Task :lib:javaPreCompileDebug
> Task :lib:compileDebugJavaWithJavac
> Task :lib:extractDebugAnnotations
> Task :lib:processDebugJavaRes NO-SOURCE
> Task :lib:transformResourcesWithMergeJavaResForDebug
> Task :lib:transformClassesAndResourcesWithSyncLibJarsForDebug
> Task :lib:mergeDebugJniLibFolders
> Task :lib:transformNativeLibsWithMergeJniLibsForDebug
> Task :lib:transformNativeLibsWithSyncJniLibsForDebug
> Task :lib:bundleDebugAar
> Task :lib:compileDebugSources
> Task :lib:assembleDebug

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 28s
59 actionable tasks: 58 executed, 1 up-to-date

Gradle log after incremental build: not mentioning google-services.json

Executing tasks: [:app:assembleMasterRelease] in project C:srchmdmandroid-kiosk


> Configure project :app
Copying common files to all enterprise build variants

> Task :app:copyFiles NO-SOURCE
> Task :app:preBuild UP-TO-DATE
> Task :app:injectCrashlyticsMappingFileIdMasterRelease UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:preMasterReleaseBuild UP-TO-DATE
> Task :app:compileMasterReleaseAidl UP-TO-DATE
> Task :app:compileMasterReleaseRenderscript NO-SOURCE
> Task :app:checkMasterReleaseManifest UP-TO-DATE
> Task :app:generateMasterReleaseBuildConfig UP-TO-DATE
> Task :app:processMasterReleaseGoogleServices UP-TO-DATE
> Task :app:generateMasterReleaseSources UP-TO-DATE
> Task :app:dataBindingExportBuildInfoMasterRelease UP-TO-DATE
> Task :app:dataBindingExportFeaturePackageIdsMasterRelease UP-TO-DATE
> Task :app:dataBindingMergeDependencyArtifactsMasterRelease UP-TO-DATE
> Task :app:dataBindingMergeGenClassesMasterRelease UP-TO-DATE
> Task :app:generateMasterReleaseResValues UP-TO-DATE
> Task :app:generateMasterReleaseResources UP-TO-DATE
> Task :app:mergeMasterReleaseResources
> Task :app:dataBindingGenBaseClassesMasterRelease UP-TO-DATE
> Task :app:javaPreCompileMasterRelease UP-TO-DATE
> Task :app:mainApkListPersistenceMasterRelease UP-TO-DATE
> Task :app:createMasterReleaseCompatibleScreenManifests UP-TO-DATE
> Task :app:processMasterReleaseManifest UP-TO-DATE
> Task :app:processMasterReleaseResources

> Task :app:compileMasterReleaseJavaWithJavac
Gradle may disable incremental compilation as the following annotation processors are not incremental: databinding-compiler-3.4.1.jar (androidx.databinding:databinding-compiler:3.4.1).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run annotation processing in a separate task and make compilation incremental.
warning: loading is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap loading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutactivity_main.xml Line:50
warning: downloading is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap downloading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutactivity_main.xml Line:63
warning: downloading is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap downloading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutactivity_main.xml Line:72
warning: showContent is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap showContent with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutactivity_main.xml Line:98
warning: error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_server.xml Line:41
warning: !error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap !error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_server.xml Line:47
warning: error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_password.xml Line:40
warning: !error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap !error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_password.xml Line:46
warning: loading is a boxed field but needs to be un-boxed to execute bind:boolToDisable. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap loading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_password.xml Line:52
warning: loading is a boxed field but needs to be un-boxed to execute bind:boolToDisable. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap loading with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_password.xml Line:67
warning: error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_device_id.xml Line:40
warning: !error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap !error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_device_id.xml Line:47
warning: error is a boxed field but needs to be un-boxed to execute bind:boolToVisible. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
  file://C:srchmdmandroid-kioskappsrcmainreslayoutdialog_enter_device_id.xml Line:91
warning: downloadedLength is a boxed field but needs to be un-boxed to execute String.valueOf(downloadedLength). This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap downloadedLength with safeUnbox() to prevent the warning
warning: fileLength is a boxed field but needs to be un-boxed to execute String.valueOf(fileLength). This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap fileLength with safeUnbox() to prevent the warning
warning: error is a boxed field but needs to be un-boxed to execute !error. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
warning: error is a boxed field but needs to be un-boxed to execute !error. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
warning: error is a boxed field but needs to be un-boxed to execute !error. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap error with safeUnbox() to prevent the warning
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
18 warnings

> Task :app:compileMasterReleaseSources
> Task :app:mergeMasterReleaseShaders UP-TO-DATE
> Task :app:lintVitalMasterRelease
> Task :app:compileMasterReleaseShaders UP-TO-DATE
> Task :app:generateMasterReleaseAssets UP-TO-DATE
> Task :app:mergeMasterReleaseAssets UP-TO-DATE
> Task :app:validateSigningMasterRelease UP-TO-DATE
> Task :app:signingConfigWriterMasterRelease UP-TO-DATE
> Task :app:checkMasterReleaseDuplicateClasses UP-TO-DATE
> Task :app:transformClassesWithDexBuilderForMasterRelease
> Task :app:transformClassesWithMultidexlistForMasterRelease
> Task :app:transformDexArchiveWithDexMergerForMasterRelease
> Task :app:mergeMasterReleaseJniLibFolders UP-TO-DATE
> Task :app:transformNativeLibsWithMergeJniLibsForMasterRelease UP-TO-DATE
> Task :app:processMasterReleaseJavaRes NO-SOURCE
> Task :app:transformResourcesWithMergeJavaResForMasterRelease UP-TO-DATE
> Task :app:packageMasterRelease
> Task :app:assembleMasterRelease

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 12s
34 actionable tasks: 8 executed, 26 up-to-date

Answer

Same issue, fixed it by downgrading the Crashlytics Gradle plugin version to 2.1.1.

Crashlytics Gradle plugin version 2.2.0 This update to firebase-crashlytics-gradle includes several changes to Crashlytics task configuration and dependency declarations, which improves incremental build performance and fixes several known issues.