错误:修复版本冲突(google-services插件)

Fai*_*her 66 android firebase google-play-services firebase-cloud-messaging

根据这个 SO线程,我知道存在版本冲突,但是在谷歌的新版本之后问题仍然存在.

错误:任务':app:processDebugGoogleServices'的执行失败.请通过更新google-services插件的版本来修复版本冲突(有关最新版本的信息,访问https://bintray.com/android/android-tools/com.google.gms.google-services/)或将com.google.android.gms的版本更新为10.0.1.

我的build.gradle(模块:app)

....
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'
Run Code Online (Sandbox Code Playgroud)


现在需要做哪些改变?

Adi*_*yad 56

我想你改变了

compile 'com.google.firebase:firebase-messaging:11.0.4'
Run Code Online (Sandbox Code Playgroud)

  • 确保所有Firebase SDK版本与播放服务版本相同. (4认同)

Arn*_*Rao 37

当抛出相同的错误时

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

未添加到模块build.gradle文件的底部.

  • 这对我有用,我只是将它添加到文件的底部 (3认同)
  • 救了我!人们不得不怀疑,为什么Gradle闻起来像黑魔法一样多。 (2认同)

Ngu*_*iếu 30

您必须只为所有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'
Run Code Online (Sandbox Code Playgroud)

或者仅对3个库使用10.0.1


小智 21

请更改您build.gradle必须更改依赖项类路径google-servicesbuild.gradle路径的项目级文件.

buildscript {

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}
Run Code Online (Sandbox Code Playgroud)


Zoe*_*Zoe 20

谷歌播放服务要求其所有依赖项具有相同的版本.但是,如果你看看你的依赖项:

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'
Run Code Online (Sandbox Code Playgroud)

有一个版本不同.

可以通过将版本更改为(在本例中)来解决11.0.4.

这适用于Firebase和Google Play服务 - 两者都必须具有相互匹配的匹配版本.如果Firebase依赖项10.0.1与Google Play服务相关性11.0.4相同,则会发生相同的错误.

请注意,在某些情况下,可能有一个库具有不同版本的库(例如,当您在应用程序中使用依赖项时库x使用)play-services-games:10.0.111.0.4


编辑

这个答案不包括版本个别的新版本.更新com.google.gms:google-services:4.1.0并检查mvnrepository(或其他一些maven/gradle artifact搜索工具)以查找最新版本.


小智 5

为了正确安装fire base,所有版本的fire base compiles必须在同一个版本中

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'
Run Code Online (Sandbox Code Playgroud)

这是正确的方法.


Bla*_*o73 5

com.android.tools.build:gradle:3.2.0
Run Code Online (Sandbox Code Playgroud)

您必须使用:

classpath 'com.google.gms:google-services:4.1.0'
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题