版本冲突升级到8.4.0

Version conflict updating to 8.4.0

错误:

Execution failed for task ':app:processDebugGoogleServices'. Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available here) or updating the version of com.google.android.gms to 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
        }

并且在应用程序中 gradle

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

为项目使用这些依赖项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 文件进行比较,并添加或修改与我所写内容不同的任何值。

这是我的修复说明。

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

重要的是将Gradle设置为版本2.10

在官方例子中找到

在项目中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-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()
    }
}

在应用程序中 gradle

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'

执行以下操作:

  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。

Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable

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

    的底部
    apply plugin: 'com.google.gms.google-services
    

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

移动中:

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

到最后一行解决了问题。

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

为您启用的服务所需的基本库添加依赖项。此步骤要求应用插件:'com.google.gms.google-services' 行位于 app/build.gradle 文件的末尾,以便不会引入依赖项冲突。 通过运行./gradlew :app:dependencies.

可以看到这一步的结果

在项目中gradle

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

在 app/module gradle

apply plugin: 'com.google.gms.google-services'
android {
    ...
}

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

将 apply plugin: 'com.google.gms.google-services' 移动到 build.gradle 的末尾没有任何意义。等同于没有定义。

只需删除此行并确保应用插件:“com.android.application”存在

使用:

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

它将编译。

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

顶级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 版,请确保重新生成您的配置文件,因为它有新字段(解释 ).

编辑 (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.

对我来说只有这个:

顶级。

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'

我已经在应用程序中更新了 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'
}

它正在为.

工作

在项目gradle中:

       compileSdkVersion 23

正在运行。

在我的例子中,我删除了 "apply plugin: 'com.google.gms.google-services'" 从 gradle.build 的末尾开始工作正常。