【问题标题】:Android Version Conflict for Google ServicesGoogle 服务的 Android 版本冲突
【发布时间】:2018-01-04 11:15:08
【问题描述】:

我已经为此搜索了很多解决方案,但没有一个适合我的确切情况。我在 Gradle Sync 上收到此错误:

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

请通过更新 google-services 插件的版本(有关最新版本的信息可在 https://bintray.com/android/android-tools/com.google.gms.google-services/ 获得)或将 com.google.android.gms 的版本更新到 11.4.2 来解决版本冲突。

这是在我的 build.gradle (app) 依赖项中。

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'

如果我将鼠标悬停在它上面,我会收到消息:

所有 gms/firebase 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 11.8.0、11.4.2。示例包括 com.google.android.gms:play-services-auth:11.8.0 和 com.google.firebase:firebase-analytics:11.4.2

我什至没有分析依赖!

我该怎么办?

已经尝试过的解决方案:

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

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

将 google play services 版本更改为 3.1.1 或更低版本将无济于事。

【问题讨论】:

  • 用问题分享你的整个Build.Gradle
  • @Nilu 检查上面编辑的答案。

标签: android firebase google-play-services version firebase-analytics


【解决方案1】:

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

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

另外,请确保您在 build.gradle (app) 文件的底部有这个:

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

【讨论】:

  • 当然可以。但它给我一个 lint 错误。说有新版本可用。难道不降级就没有办法了吗?
  • 在这种情况下,您需要升级与 firebase 11.8.0 匹配的 google 服务依赖项。或者尝试添加两个最新版本。那应该可以解决问题
  • 我的谷歌服务版本是 3.1.2 - 最新的。我如何更改为 com.google.android.gms:play-services:11.8.0 而不会引发 lint 错误。
  • 解决了一切!编辑您的答案,以便我将其标记为正确答案!
  • 只是因为我忽略了它,也许其他人可能会:// ADD THIS AT THE BOTTOM ... apply plugin: 'com.google.gms.google-services' ... 非常重要
【解决方案2】:

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

【讨论】:

  • 粘贴应用级别和项目级别的 gradle 文件。
  • 检查我上面编辑的答案。它们都是android库。
  • 您确定您的 libs 文件夹和项目中的其他模块中没有任何内容吗?
【解决方案3】:

尝试将其从 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'

【讨论】:

    【解决方案4】:

    改变这个

     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 依赖项

    【讨论】:

    • 这没有任何作用。而且,我相信implementation 是推荐的新方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-25
    • 1970-01-01
    • 2017-07-26
    • 2017-02-11
    • 1970-01-01
    • 2016-12-14
    相关资源
    最近更新 更多