当我在 Android Studio 中进行增量构建时,Firebase Crashlytics 崩溃 'The Crashlytics build ID is missing'

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

我正在我的 Android 应用程序中添加 Firebase Crashlytics。我仔细按照 https://firebase.google.com/docs/crashlytics/get-started?platform=android.

中的说明进行操作

当我重建 运行 应用程序(在 Android Studio 中)时,一切正常,我能够收到崩溃报告。

但是:当我在 Android Studio 中对我的代码进行一些更改并重新 运行 应用程序时,它崩溃并显示以下报告。

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[=12=](Unknown Source:0)
07-25 17:30:40.918 24237 24237 E AndroidRuntime:        at com.google.firebase.crashlytics.CrashlyticsRegistrar$$Lambda.create(Unknown Source:2)

如何解决这个问题?此行为是否与此处报告的 Firebase 问题有关? https://github.com/firebase/firebase-android-sdk/issues/1523

我正在使用以下依赖项:

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

更新:Gradle完整和增量构建的构建日志。

Gradle 完全重建后的日志:包含 google-services.json

的解析
Executing tasks: [clean, :app:assembleMasterRelease, :lib:assembleDebug] in project C:\src\hmdm\android-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:\src\hmdm\android-kiosk\app\google-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:\src\hmdm\android-kiosk\app\src\main\res\layout\activity_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:\src\hmdm\android-kiosk\app\src\main\res\layout\activity_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:\src\hmdm\android-kiosk\app\src\main\res\layout\activity_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:\src\hmdm\android-kiosk\app\src\main\res\layout\activity_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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 增量构建后的日志:未提及 google-services.json

Executing tasks: [:app:assembleMasterRelease] in project C:\src\hmdm\android-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:\src\hmdm\android-kiosk\app\src\main\res\layout\activity_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:\src\hmdm\android-kiosk\app\src\main\res\layout\activity_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:\src\hmdm\android-kiosk\app\src\main\res\layout\activity_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:\src\hmdm\android-kiosk\app\src\main\res\layout\activity_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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:\src\hmdm\android-kiosk\app\src\main\res\layout\dialog_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

同样的问题,已通过将 Crashlytics Gradle 插件版本降级到 2.1.1 来解决。

Crashlytics Gradle 插件版本 2.2.0 firebase-crashlytics-gradle 的此更新包括对 Crashlytics 任务配置和依赖项声明的几处更改,这提高了增量构建性能并修复了几个已知问题。

如果您想升级 Crashlytics Gradle v2.2.0+,请先尝试升级您的 gradle 版本

在 gradle/wrapper/gradle-wrapper.properties 文件中,将您的 gradle 版本升级到 5.6.4
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

我曾经 运行 我的应用使用 gradle 5.1.1,升级到版本 5.6.4 解决了我的问题

希望对您有所帮助!