google-services.json文件中没有找到与任何模块的包名匹配的客户端。

4

我将我的应用程序模块从app重命名为presentation模块。

  • 我将google-services.json放在我的presentation/目录下
  • 添加了classpath "com.google.gms:google-services:3.1.0"
  • 添加插件:apply plugin: 'com.google.gms.google-services'

当我尝试同步gradle时,我遇到了错误:

Error:Execution failed for task ':presentation:processDebugGoogleServices'.
No matching client found for package name 'ru.company.acitive.activelife'

我的build.gradle代码片段:

dependencies {
    classpath "com.android.tools.build:gradle:$android_plugin_version"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "com.google.gms:google-services:3.1.0"
}

我的presentation/build.gradle片段:

dependencies {

...

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
3个回答

7
这意味着您的应用程序ID是“ru.company.acitive.activelife”,但在您的google-services.json文件中找不到相同的字符串。
看起来“acitive”这部分有一个错字。它应该改成“active”吗?

我也遇到了同样的问题。看了你的答案后,我再次检查发现我的gradle文件中有一个错别字。我在gradle中写成了com.example.developmnet,但Firebase中是com.example.development - Hasan Abdullah

1
在我的应用级别的build.gradle文件中,以下行是罪魁祸首:
applicationIdSuffix ".debug"

我从另一个开发人员那里继承了代码库,所以一开始我不知道这行代码的存在。


1
除了保证 gradle androidApplicationID 与 google-services.json 匹配(如 此处 所述),此消息还可能由于 gradle 无法找到您的密钥库文件而导致。
请确保在项目级 build.gradle 文件中具有以下条目:
keystoreStoreFile = _________
keystoreStorePassword = ____________
keystoreKeyAlias = _______________
keystoreKeyPassword = ____________

请确保在“生成已签名 APK”操作期间,Android Studio提示您使用相同的四个值。
在我的情况下,我正在尝试构建谷歌提供的示例应用程序ClassyTaxi,以说明订阅服务。它有一个项目级别的build.gradle文件,引用了keystorePropertiesFile = keystore.properties。该属性文件不存在,但有一个名为example-keystore.properties的示例文件,我将其重命名为keystore.properties并填充了我选择的四个值。然后,我在使用Android Studio生成我的已签名APK时使用了完全相同的四个值。

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