错误:任务“:app:processDebugGoogleServices”执行失败。将 com.google.android.gms 版本更新至 10.2.6

2024-02-24

我正在尝试通过 Firebase 在我的 Android 应用程序中实现 Google 登录,并且在 Gradle 同步后不断出现以下消息:

错误:任务“:app:processDebugGoogleServices”执行失败。 请通过更新 google-services 插件的版本来解决版本冲突(有关最新版本的信息可在https://bintray.com/android/android-tools/com.google.gms.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'

对所有 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'
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误:任务“:app:processDebugGoogleServices”执行失败。将 com.google.android.gms 版本更新至 10.2.6 的相关文章

随机推荐