类型 'UploadMappingFileTask' 属性 'googleServicesResourceRoot' 没有配置值

Type 'UploadMappingFileTask' property 'googleServicesResourceRoot' doesn't have a configured value

更新类路径后,我无法再构建应用程序的发布版本。

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:uploadCrashlyticsMappingFileRelease' (type 'UploadMappingFileTask').
  - Type 'UploadMappingFileTask' property 'googleServicesResourceRoot' doesn't have a configured value.
    
    Reason: This property isn't marked as optional and no value has been configured.
    
    Possible solutions:
      1. Assign a value to 'googleServicesResourceRoot'.
      2. Mark property 'googleServicesResourceRoot' as optional.



    A problem was found with the configuration of task ':app:uploadCrashlyticsMappingFileRelease' (type 'UploadMappingFileTask').
  - Type 'UploadMappingFileTask' property 'googleServicesResourceRoot' doesn't have a configured value.

我试图阅读变更日志,但没有关于它的指南或文档。

我也没有找到任何东西,现在换成 firebase-crashlytics-gradle 到 2.6.1 似乎没问题。

要修复它,Google 服务插件应该在 /app/build.gradle 中的任何 Firebase 插件之前应用。

这会产生错误:

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

虽然这不是:

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

注意 com.google.gms.google-servicesABOVE com.google.firebase.crashlytics.

当您更新到 com.google.firebase:firebase-crashlytics-gradle:2.7.0 并同步更改时,您会收到一条消息,说明修复如下:

Configure project :app
Crashlytics could not find Google Services plugin task: processReleaseGoogleServices. Make sure com.google.gms.google-services is applied BEFORE com.google.firebase.crashlytics. If you are not using the Google Services plugin, you must explicitly declare `googleServicesResourceRoot` inputs for Crashlytics upload tasks.

确保

'com.google.gms.google-services'

适用于:

'com.google.firebase.crashlytics'

为我修正了错误。

我的项目没有使用 'com.google.gms.google-services'。您需要将 'com.google.gms.google-services' 添加到插件中的应用级别 Gradle 文件,并在项目级别 Gradle 文件中添加其对应的类路径依赖项 classpath 'com.google.gms:google-services:latest-version'

还要确保 com.google.gms.google-services 出现在 com.google.firebase.crashlytics 之前,如其他答案所述。