Android Google 服务的版本冲突

Android Version Conflict for Google Services

我为此搜索了很多解决方案,但 none 完全符合我的情况。我在 Gradle 同步时收到此错误:

错误:任务“:app:processDebugGoogleServices”执行失败。

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.

这是我的 build.gradle(应用程序)依赖项。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:design:27.0.2'
    implementation 'com.google.firebase:firebase-firestore:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

这是我的项目级别 build.gradle

buildscript {
    ext.kotlin_version = '1.2.10'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:3.1.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

同样重要: 它在这条线下面显示一条红线:

implementation 'com.google.firebase:firebase-auth:11.8.0'

将鼠标悬停在上面时收到的消息:

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.8.0, 11.4.2. Examples include com.google.android.gms:play-services-auth:11.8.0 and com.google.firebase:firebase-analytics:11.4.2

我什至没有分析依赖!

我该怎么办?

已经尝试过的解决方案:

如果我尝试更改我的 com.google.android.gms 版本,它会提示我不要将我的整个播放服务捆绑在依赖项中。而且它也不会改变我得到的 firebase 错误。

将 firebase 更改为 11.4.2 会引发 lint 错误。

将 google 播放服务版本更改为 3.1.1 或更低版本将不起作用。

如果我没记错的话,Google 服务依赖于 firebase。我认为两者是矛盾的

检查此 firebase.google.com/docs/android/setup 并调整 google 服务和 firebase 依赖版本

此外,请确保您的 build.gradle (app) 文件底部有此内容:

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

改变这个

 implementation 'com.google.firebase:firebase-auth:11.8.0'

compile'com.google.firebase:firebase-auth:11.8.0'

并确保在你的 applevel build.gradle 中所有 google 和 firebase 依赖版本应该相同。

它不起作用尝试从 applevel build.gradle

中删除 google 依赖项

您的项目中可能有一些第三方库使用 com.google.firebase:firebase-analytics:11.4.2 版本的 Analytics。试着找到那个。

尝试将它从 11.8.0 更改为 11.4.2 对我有用。 旧值

implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'

新价值观

implementation 'com.google.firebase:firebase-firestore:11.4.2'
implementation 'com.google.firebase:firebase-auth:11.4.2'
implementation 'com.google.firebase:firebase-messaging:11.4.2'