根据 this SO 线程,我知道存在版本冲突,但在 Google 发布新版本后问题仍然存在。
错误:任务“:app:processDebugGoogleServices”执行失败。请通过更新 google-services 插件的版本来修复版本冲突(有关最新版本的信息可在 https://bintray.com/android/android-tools/com.google.gms.google-services/ 获得)或将 com.google.android.gms 的版本更新为 10.0.1。
我的 build.gradle(模块:应用程序)
....
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
}
apply plugin: 'com.google.gms.google-services'
现在需要做哪些改变?
我觉得你变了
compile 'com.google.firebase:firebase-messaging:11.0.4'
时抛出相同的错误
apply plugin: 'com.google.gms.google-services'
未添加到模块 build.gradle
文件的底部。
您必须对所有 3 个库仅使用一个版本
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
或仅对 3 个库使用 10.0.1
请更改您的项目级 build.gradle
文件,您必须在其中更改 google-services
或 build.gradle
路径的依赖项类路径。
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
}
}
google play 服务要求其所有依赖项具有相同的版本。但是,如果您查看您的依赖项:
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
有一个版本不同。
可以通过将版本更改为(在本例中)11.0.4
来解决。
这适用于 Firebase 和 Google Play 服务 - 两者都必须具有相互对应的匹配版本。如果 Firebase 依赖项是 10.0.1
,而 Google Play Services 依赖项是 11.0.4
,则会发生相同的错误。
请注意,在某些情况下,可能存在具有不同版本库的库(例如,库 x
使用 play-services-games:10.0.1
,而您将 11.0.4
用于应用程序中的依赖项)
编辑
此答案不涵盖版本是单独的较新版本。更新 com.google.gms:google-services:4.1.0
并检查 mvnrepository(或其他一些 maven/gradle 工件搜索工具)以查找最新版本。
和
com.android.tools.build:gradle:3.2.0
你必须使用:
classpath 'com.google.gms:google-services:4.1.0'
这解决了我的问题
为了正确安装火基地,所有版本的火基地编译必须是相同的版本,所以
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
这是正确的方法。
最初,firebase 数据库指向 11.8.0 。将所有相关 jar 更改为 11.0.4 后,此问题在更改 SDK 级别时得到解决。
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'
重要更新
Firebase 和 Play-service 依赖项都具有与过去不同的独立版本。如果您有版本冲突,那么您可以更新您的 com.google.gms:google-services。并开始定义独立版本。
步骤(1):更新 com.google.gms:google-services
打开项目级别 build.gradle 并将 com.google.gms:google-services 更新到版本 4.1.0 如果可用,必须检查更新。
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0' //< update this
}
}
步骤 (2):更新 Firebase 依赖项最新版本
Firebase 依赖版本可以是单独的。
com.google.firebase:firebase-core:16.0.3 //Analytics, check latest too
com.google.firebase:firebase-database:16.0.2 //Realtime Database, check latest too
步骤 (3):更新 Play Services 依赖项最新版本
播放服务版本也可以有单独的版本。
com.google.android.gms:play-services-ads:17.1.2 //Ads, check latest too
com.google.android.gms:play-services-analytics:16.0.6 //Analytics, check latest too
仍有问题?您可以通过阅读 this answer 来检查哪个依赖项产生了冲突。
将谷歌服务和 Firebase 库更新到最新版本
谷歌服务
classpath 'com.google.gms:google-services:4.3.1'
火力基地
implementation 'com.google.firebase:firebase-database:19.0.0'
正如消息所说,转到:com.google.gms.google-services versions
并复制上一个版本的编号。我的低于 3.3.1。然后在项目的 build.gradle put/change dependencies 节点中:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' // as it was before
classpath 'com.google.gms:google-services:3.3.1' // <-- the version change
}
然后我同步了项目并且出错了
所有谷歌服务应该是相同的版本,尝试匹配每个版本。
正确的一个是:
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-database:11.6.0'
不正确的配置是:
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
After All Working for 6 hours i got the solution...
Simple Just what ever the plugins you defined in the build.gradle file... for ex: google services plugins or firebase plugins or any third party plugins all the **version code** should be same..
Example: In my application i am using following plugins...
// google services plugins
implementation 'com.google.android.gms:play-services-analytics:10.0.1'
implementation 'com.google.android.gms:play-services-gcm:10.0.1'
implementation 'com.google.android.gms:play-services-base:11.6.1'
implementation 'com.google.android.gms:play-services-auth-api-phone:11.6.0'
//firebase plugin
implementation 'com.google.firebase:firebase-ads:10.0.1'
//Third Party plugin
implementation 'com.google.android.gms:play-services-auth:16.0.0'
在上述插件版本代码(例如:10.0.1、16.0.0、11.6.1)中不同我面临修复版本冲突(google-services 插件)问题
Below for all plugins i have given single version code(11.6.0) and the issue is resovled...
// google services plugins
implementation 'com.google.android.gms:play-services-analytics:11.6.0'
implementation 'com.google.android.gms:play-services-gcm:11.6.0'
implementation 'com.google.android.gms:play-services-base:11.6.0'
implementation 'com.google.android.gms:play-services-auth-api-phone:11.6.0'
//firebase plugin
implementation 'com.google.firebase:firebase-ads:11.6.0'
//Third Party plugin
implementation 'com.google.android.gms:play-services-auth:11.6.0'
**Syn Gradle**...
Go to Build>>Rebuild Projcet...
Sure it will work....@Ambilpura
安装或更新谷歌播放服务。其次,检查您的 'com.google.gms:google-services:3.0.0' 版本。检查,如果仍然无法使用,请将其升级到 3.1.0