类型为“UploadMappingFileTask”的属性“googleServicesResourceRoot”没有配置值。

80

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

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.

我尝试阅读更新日志,但没有相关的指南或文档。

6个回答

142
为了解决这个问题,在 /app/build.gradle 中应该先使用 Google 服务插件,再使用 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-services高于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.

9
我记得把那行放在底部(参见这里)...现在它又改变了... - Vall0n
1
@Vall0n 他们在文档中将其更改为位于顶部: https://firebase.google.com/docs/android/setup#add_the_sdk - MBH
问题已经解决,但Gradle开始显示警告:“警告:请在构建文件底部应用google-services插件。” :) - Guy

22

确保

'com.google.gms.google-services'

应用于之前:

'com.google.firebase.crashlytics'

对我来说修复了错误。


1
这对于新版本来说是个好办法,但在旧版本中并不是问题。 - Hanzala

5

目前我没有找到任何有用的信息,不过将firebase-crashlytics-gradle升级到2.6.1似乎可以解决问题。


3
真烦人,需要支持。 - Bitwise DEVS
你找到解决方案了吗? - casolorz
1
@casolorz 他们正在这里查看 https://github.com/firebase/firebase-android-sdk/issues/2721 - Bitwise DEVS
2
谢谢,我已经切换回2.6.1版本了,现在可以正常工作。 - casolorz

4

当我在测试minifyEnabled true时,这种情况发生在我的debug构建中。

将以下内容添加到我的debug buildTypes中,问题得到了解决。

      firebaseCrashlytics
          {
            mappingFileUploadEnabled false
          }

1

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

此外,请确保com.google.gms.google-services出现在其他答案所述的com.google.firebase.crashlytics之前。


0

我已经按正确顺序添加了应用插件行,但仍然出现构建错误和同步警告,指出找不到插件任务。我考虑升级google-services的可能性,但版本4.1.0已经是我能达到的最高版本。如果再高,就会出现找不到库依赖项的错误。

事实证明,我不仅需要将google-services升级到4.3.14,还需要在项目级别的build.gradle中定义存储库;它还需要在应用程序级别的build.gradle中定义。

buildscript {
    repositories {
        google()
        mavenCentral() // Add this line
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.14'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

在“入门指南”文档中并没有提到需要这样做,所以希望这能帮助到任何陷入和我一样情况的人。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接