【问题标题】:Version conflict updating to 8.4.0版本冲突更新到 8.4.0
【发布时间】:2016-03-26 01:08:03
【问题描述】:

错误:

任务“:app:processDebugGoogleServices”执行失败。请 通过更新版本来修复版本冲突 google-services 插件(有关最新版本的信息是 available here) 或将 com.google.android.gms 的版本更新为 8.3.0。

我已经完成了所有我发现的事情。

  dependencies {
            // This does not break the build when Android Studio is missing the JRebel for Android plugin.
            classpath 'com.zeroturnaround.jrebel.android:jr-android-gradle:1.0.+'
            classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
            classpath 'com.google.gms:google-services:2.0.0-alpha3'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }

并且在应用程序中

    compile 'com.google.android.gms:play-services:8.4.0'

【问题讨论】:

    标签: android google-play-services


    【解决方案1】:

    将这些依赖项用于项目 build.gradle

    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
        classpath 'com.google.gms:google-services:2.0.0-alpha3'
    }
    

    并将其放在应用程序级 build.gradle 文件的末尾(在依赖项之后)。

    apply plugin: 'com.google.gms.google-services'
    

    我不知道为什么把它放在最后(而不是放在开头)可以解决错误。

    2016 年 5 月 1 日编辑

    好的……所以尝试结束你们在我的解决方案中遇到的所有问题

    这是我的最终应用程序级别 gradle

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
    
        defaultConfig {
            applicationId "your-app-name"
            minSdkVersion 16
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    repositories {
        jcenter()
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.google.android.gms:play-services:8.4.0'
        compile 'com.android.support:design:23.1.1'
        compile 'com.mcxiaoke.volley:library:1.0.6@aar'
    }
    
    apply plugin: 'com.google.gms.google-services'
    

    这是我的最终项目级 gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
            classpath 'com.google.gms:google-services:2.0.0-alpha3'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    

    将此与您自己的 gradle 文件进行比较,并添加或修改任何与我编写的不同的值。

    【讨论】:

    • compile 'com.google.android.gms:play-services-auth:8.4.0 也是必需的。
    • 我总是想知道人们是如何偶然发现这样的解决方案的。试错?神圣卷轴?
    • 为什么将 apply plugin: 'com.google.gms.google-services' 放在 build.gradle 文件的末尾并放在开头会失败?
    • 以上解决方案均不适用于 8.4.0。在保存 build.gradle 后执行第二次“重建项目”后全部失败。第一个构建工作(或不会大声失败),第二个给出关于 8.3.0 与 8.4.0 的错误。使用 'com.google.android.gms:play-services' 而不是个人失败了。使用 (`classpath 'com.google.gms:google-services:2.0.0-alpha3'`) 失败并出现其他错误(在第二次构建时),所以我使用 1.5.0。使用非 Studio Preview 并没有什么不同。
    • 重要提示不要忘记添加您的 google-services.json 文件!否则它将失败并显示消息“模块根文件夹中缺少文件 google-services.json”。您可以在此处创建文件:developers.google.com/analytics/devguides/collection/android/v4 正如文档所说,接下来您将将此文件添加到 projectFolder/app (即您的应用程序模块的根目录)。
    【解决方案2】:

    在应用程序的模块(build.gradle)中

    移动:

    apply plugin: 'com.google.gms.google-services'
    

    到最后一行解决了问题。

    【讨论】:

    • 对于任何想知道为什么将apply plugin:... 行移到末尾的人,它是because of this: "此步骤需要应用插件:'com.google.gms.google-services'行位于 app/build.gradle 文件的底部,这样就不会引入依赖冲突。您可以通过运行 ./gradlew :app:dependencies 来查看此步骤的结果。"
    【解决方案3】:

    执行以下操作:

    1. 将以下内容放入您的 build.gradle(应用程序级 gradle 文件)

      dependencies {
            classpath 'com.android.tools.build:gradle:2.0.0-beta2'
            classpath 'com.google.gms:google-services:2.0.0-beta2'
      }
      

    请查看here 获取最新版本,因为这会不断变化。

    1. 如果您收到以下错误消息,则需要将 gradle 包装器升级到 gradle-wrapper.properties 中的最新版本。我正在使用 2.10。

    插件太旧,请更新到最新版本,或设置ANDROID_DAILY_OVERRIDE环境变量

    1. 将以下行放在 build.gradle(模块级 gradle 文件)的底部

      apply plugin: 'com.google.gms.google-services
      

    【讨论】:

    • 在我的 build.gradle 的底部添加应用插件行为我修复了它。谢谢!
    • 很高兴您指定检查链接以获取最新版本。没有一个以 beta 为后缀的版本对我有用,我不知道人们从哪里获得所有这些版本。 2.12 终于为我工作了。
    【解决方案4】:

    这似乎已在 3.0.0 版的 Google 服务插件(以及 9.0.0 版的 Google Play 服务库)中得到修复。所以有了这个

    顶级 build.gradle

    dependencies {
        classpath 'com.google.gms:google-services:3.0.0'
    }
    

    应用级 build.gradle

    apply plugin: 'com.google.gms.google-services'
    
    dependencies {
        compile 'com.google.android.gms:play-services:9.0.0
    }
    

    快速旁注:如果您要更新到 google-services 插件的 3.0.0 版,请确保重新生成您的配置文件,因为它具有新字段(解释为 here)。

    编辑 (2016-06-20): 虽然它确实可以编译并运行,但我只是注意到在构建日志中它确实指定将插件放在文件的底部,或者将使用默认值 (9.0.0)。因此,在上述情况下,这不是问题,因为我使用的是 9.0.0 版本,但是在更新依赖项时这可能会出现问题。这是日志:

    google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used. please apply google-services plugin at the bottom of the build file.

    【讨论】:

      【解决方案5】:

      对我来说只有这个:

      顶级。

      dependencies {
          classpath 'com.android.tools.build:gradle:2.1.0'
          classpath 'com.google.gms:google-services:3.0.0'
      }
      

      应用级别:

      dependencies {
          compile 'com.google.android.gms:play-services-gcm:9.0.1'
          compile 'com.google.android.gms:play-services-location:9.0.1'
      }
      
      // should be at the bottom
      apply plugin: 'com.google.gms.google-services'
      

      【讨论】:

      • 将apply plugin: 'com.google.gms.google-services' 移到底部完成了我的项目的工作
      • 应该在底部是这里的关键因素
      【解决方案6】:

      在官方示例中找到

      在项目分级中

      // Top-level build file where you can add configuration options common to all sub-projects/modules.
      
      buildscript {
          repositories {
              jcenter()
          }
          dependencies {
              classpath 'com.android.tools.build:gradle:2.0.0-alpha9'
              classpath 'com.google.gms:google-services:2.0.0-alpha9'
      
              // NOTE: Do not place your application dependencies here; they belong
              // in the individual module build.gradle files
          }
      }
      
      allprojects {
          repositories {
              jcenter()
          }
      }
      

      在应用程序中

      apply plugin: 'com.android.application'
      
      android {
          compileSdkVersion 23
          buildToolsVersion "23.0.2"
      
          defaultConfig {
              applicationId "com.google.samples.quickstart.signin"
              minSdkVersion 18
              targetSdkVersion 23
              versionCode 1
              versionName "1.0"
      
              testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          }
      
          buildTypes {
              release {
                  minifyEnabled false
                  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              }
          }
      
          packagingOptions {
              exclude 'LICENSE.txt'
          }
      
          // Resolve dependency differences between app and tests
          configurations.all {
              resolutionStrategy.force 'com.android.support:support-annotations:23.1.1'
          }
      }
      
      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
          compile 'com.android.support:appcompat-v7:23.1.1'
          compile 'com.android.support:design:23.1.1'
      
          // Dependency for Google Sign-In
          compile 'com.google.android.gms:play-services-auth:8.4.0'
      
          // UiAutomatorTesting
          androidTestCompile 'com.android.support.test:runner:0.4.1'
          androidTestCompile 'com.android.support.test:rules:0.4.1'
          androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
          androidTestCompile 'com.android.support:support-annotations:23.1.1'
      }
      
      apply plugin: 'com.google.gms.google-services'
      

      【讨论】:

      • 使用alpha9 为我工作了Gradle 2.11。这次真是万分感谢!能否请您链接到官方示例,也许它对此类其他问题也有帮助。
      【解决方案7】:

      我已经在 app build.gradle 中更新了

      dependencies {
      ....
      compile 'com.google.android.gms:play-services-auth:9.0.0'
      

      和应用程序 build.gradle

        dependencies {
          classpath 'com.android.tools.build:gradle:2.1.0'
          classpath 'com.google.gms:google-services:3.0.0'
      }
      

      它的工作原理。

      【讨论】:

        【解决方案8】:

        在我的情况下,我删除了“应用插件:'com.google.gms.google-services'” 从 gradle.build 的末尾开始,它的工作正常。

        【讨论】:

          【解决方案9】:

          重要的是将 Gradle 设置为 2.10 版

          https://stackoverflow.com/a/35188079/570168

          【讨论】:

            【解决方案10】:

            我正在搜索...在 Google 页面上有解决方案...https://developers.google.com/android/guides/google-services-plugin#introduction

            为您启用的服务所需的基本库添加依赖项。此步骤要求 apply plugin: 'com.google.gms.google-services' 行位于 app/build.gradle 文件的末尾,以免引入依赖冲突。 你可以通过运行 ./gradlew :app:dependencies 查看这一步的结果。

            【讨论】:

              【解决方案11】:

              将 apply plugin: 'com.google.gms.google-services' 移到 build.gradle 的末尾没有任何意义。和不定义是一样的。

              只需删除此行并确保 apply plugin: 'com.android.application' 存在

              用途:

              compile 'com.google.android.gms:play-services-gcm:8.4.0'
              compile 'com.google.android.gms:play-services:8.4.0'
              

              它会编译。

              【讨论】:

              【解决方案12】:

              在项目分级中

              buildscript {
                  repositories {
                      jcenter()
                  }
                  dependencies {
                      classpath 'com.google.gms:google-services:2.0.0-alpha6'
                  }
              }
              

              在应用程序/模块 gradle 中

              apply plugin: 'com.google.gms.google-services'
              android {
                  ...
              }
              
              dependencies {
                  compile 'com.google.android.gms:play-services-analytics:8.3.0'
              }
              

              【讨论】:

                【解决方案13】:

                在项目分级中:

                       compileSdkVersion 23
                

                它正在工作。

                【讨论】:

                  【解决方案14】:

                  这是我的修复说明。

                  1. 在应用程序build.gradle 中更改为使用compile 'com.google.android.gms:play-services-location:8.3.0'
                  2. 将apply plugin: 'com.google.gms.google-services'移动到应用末尾build.gradle
                  3. 在项目build.gradle依赖中使用classpath 'com.google.gms:google-services:2.0.0-alpha3'
                  4. 更改为在gradle/wrapper/gradle-wrapper.properties 中使用gradle-2.8

                  【讨论】:

                    猜你喜欢
                    • 2020-01-15
                    • 1970-01-01
                    • 1970-01-01
                    • 2016-12-14
                    • 1970-01-01
                    • 2019-08-07
                    • 2015-11-25
                    • 1970-01-01
                    相关资源
                    最近更新 更多