【问题标题】:Error: fix the version conflict (google-services plugin)错误:修复版本冲突(google-services 插件)
【发布时间】:2018-01-12 01:06:11
【问题描述】:

根据this 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'


现在需要进行哪些更改?

【问题讨论】:

  • 确保所有播放服务的版本相同。

标签: android firebase google-play-services firebase-cloud-messaging


【解决方案1】:

我觉得你变了

compile 'com.google.firebase:firebase-messaging:11.0.4'

【讨论】:

  • 所以,只有这才是问题所在!我希望我在发布之前尝试过:\
  • 确保所有 Firebase SDK 版本与播放服务版本相同。
  • 我遇到了同样的问题,但我的所有版本号都已更新。几分钟后,我发现它出错了,因为我在底部放了 apply plugin: 'com.google.gms.google-services' 。一旦我把它放在底部,它就起作用了。有人能解释一下为什么会这样吗?
  • 如何在 phonegap build 上解决这个问题
  • 如何在 Ionic/Cordova 构建中解决这个问题?
【解决方案2】:

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 服务依赖项是 11.0.4,则会出现同样的错误。

请注意,在某些情况下,可能存在具有不同版本库的库(例如,库 x 使用 play-services-games:10.0.1 而您使用 11.0.4 作为应用中的依赖项)


编辑

此答案不涵盖版本是单独的较新版本。更新 com.google.gms:google-services:4.1.0 并检查 mvnrepository(或其他一些 maven/gradle 工件搜索工具)以查找最新版本。

【讨论】:

【解决方案3】:

您必须为所有 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

【讨论】:

  • 太棒了。花了几个小时试图找出构建问题,因为 firebase 试图使用 17x,而 play-services-location 是 16x。谢谢
  • 更新,可以使用个别版本stackoverflow.com/a/54593656/6891563
【解决方案4】:

安装或更新谷歌播放服务。其次,检查您的 'com.google.gms:google-services:3.0.0' 版本。检查,如果仍然无法使用,请升级到 3.1.0

【讨论】:

    【解决方案5】:

    时抛出同样的错误
    apply plugin: 'com.google.gms.google-services'
    

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

    【讨论】:

    • 这对我有用,我只是将它添加到文件的底部
    • 救了我!人们不得不怀疑为什么 Gradle 闻起来像黑魔法。
    • 我想知道为什么在 Gradle 顶部设置插件行会出错,而在文件底部设置它会正常工作???有没有人知道真正的原因。
    【解决方案6】:

    最初,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'
    

    【讨论】:

      【解决方案7】:

      要正确安装 fire base,fire base 编译的所有版本必须是相同的版本,所以

      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'
      

      这是正确的做法。

      【讨论】:

        【解决方案8】:

        如消息所述,前往: 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                  
                }
        

        然后我同步了项目并且出错了

        【讨论】:

          【解决方案9】:

          所有谷歌服务应该是相同的版本,尝试匹配每个版本

          正确的是:

            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'
          

          【讨论】:

            【解决方案10】:

            请更改您的项目级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'
                }
            }
            

            【讨论】:

              【解决方案11】:

              com.android.tools.build:gradle:3.2.0
              

              你必须使用:

              classpath 'com.google.gms:google-services:4.1.0'
              

              这解决了我的问题

              【讨论】:

                【解决方案12】:

                重要更新

                Firebase 和 Play-service 依赖项都具有与过去不同的独立版本。如果 你有版本冲突然后你可以更新你的 com.google.gms:google-services。并开始定义独立版本。

                步骤(1):更新com.google.gms:google-services

                打开项目级别build.gradle 并将com.google.gms:google-services 更新到版本4.1.0 MUST CHECK newer if available

                buildscript {
                    ...
                    dependencies {
                        classpath 'com.android.tools.build:gradle:3.2.0'
                        classpath 'com.google.gms:google-services:4.1.0' //< update this 
                    }
                }
                

                步骤(2):更新 Firebase 依赖项Latest Versions

                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):更新播放服务依赖Latest Versions

                播放服务版本也可以有单独的版本。

                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 来检查哪个依赖项产生了冲突。

                【讨论】:

                  【解决方案13】:
                  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
                  

                  【讨论】:

                    【解决方案14】:

                    更新谷歌服务和 Firebase 库到最新版本

                    谷歌服务

                     classpath 'com.google.gms:google-services:4.3.1'
                    

                    火力基地

                     implementation 'com.google.firebase:firebase-database:19.0.0'
                    

                    【讨论】:

                      猜你喜欢
                      • 1970-01-01
                      • 1970-01-01
                      • 2018-03-04
                      • 1970-01-01
                      • 1970-01-01
                      • 1970-01-01
                      • 1970-01-01
                      • 1970-01-01
                      • 1970-01-01
                      相关资源
                      最近更新 更多