【问题标题】:Error:Execution failed for task ':app:processDebugGoogleServices'. Update version of com.google.android.gms to 10.2.6错误:任务“:app:processDebugGoogleServices”执行失败。将 com.google.android.gms 的版本更新到 10.2.6
【发布时间】:2017-11-14 11:08:47
【问题描述】:

我正在尝试在我的 Android 应用中通过 Firebase 实现 Google 登录,但在我的 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'

【问题讨论】:

    标签: android firebase firebase-authentication google-signin


    【解决方案1】:

    对所有 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'
    }
    

    【讨论】:

    • ext { } 真的很方便! +1
    猜你喜欢
    • 1970-01-01
    • 2016-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-28
    • 1970-01-01
    • 2019-06-29
    相关资源
    最近更新 更多