错误:任务':app:processDebugGoogleServices'的执行失败。将com.google.android.gms的更新版本更新为10.2.6

时间:2017-06-12 20:49:29

标签: android firebase firebase-authentication google-signin

我正在尝试通过Firebase将Google登录添加到我的Android应用中,并且在我的Gradle同步后,以下消息仍然显示:

  

错误:任务':app:processDebugGoogleServices'的执行失败。   请修改版本冲突,方法是更新google-services插件的版本(https://bintray.com/android/android-tools/com.google.gms.google-services/提供有关最新版本的信息)或将com.google.android.gms版本更新为10.2.6。

如何解决此错误?

这是我的Gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.sjf.lgcats"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 2
        versionName "1.0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/2'] } }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-vector-drawable:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.google.firebase:firebase-auth:10.2.6'
    compile 'com.google.firebase:firebase-messaging:10.2.6'
    compile 'com.google.firebase:firebase-auth:11.0.0'
    compile 'com.google.android.gms:play-services-auth:11.0.0'
    compile 'commons-io:commons-io:2.0.1'
    testCompile 'junit:junit:4.12'
}

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

1 个答案:

答案 0 :(得分:16)

对所有Firebase和Google Play库使用相同的版本:

compile 'com.google.firebase:firebase-auth:11.0.0'
compile 'com.google.firebase:firebase-messaging:11.0.0'
compile 'com.google.android.gms:play-services-auth:11.0.0'

在进行更改时,您还可以使用最新版本的构建工具:

buildToolsVersion "26.0.0"

您可以通过以下方式简化版本号的维护并确保它们始终保持一致:

ext {
    SUPPORT_LIB_VER = '25.3.1'
    GOOGLE_LIB_VER = '11.0.0'
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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:$SUPPORT_LIB_VER"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile "com.android.support:design:$SUPPORT_LIB_VER"
    compile "com.android.support:support-vector-drawable:$SUPPORT_LIB_VER"
    compile "com.android.support:support-v4:$SUPPORT_LIB_VER"
    compile "com.google.firebase:firebase-auth:$GOOGLE_LIB_VER"
    compile "com.google.firebase:firebase-messaging:$GOOGLE_LIB_VER"
    compile "com.google.android.gms:play-services-auth:$GOOGLE_LIB_VER"
    compile 'commons-io:commons-io:2.0.1'
    testCompile 'junit:junit:4.12'
}