【问题标题】:Conflict with firebase 11.8.0 and google-services plugin 3.1.2与 firebase 11.8.0 和 google-services 插件 3.1.2 冲突
【发布时间】:2018-01-22 22:58:57
【问题描述】:

我与 firebase 11.8.0 和 google-services 插件 3.1.2 存在明显冲突。构建失败,建议我改用 11.4.2 版的 firebase。

我的 gradle 构建文件的相关摘录:

根build.gradle

buildscript {
    repositories {
        google()
        ...
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.1.2'
        ...
    }
}

应用build.gradle:

apply plugin: 'com.google.gms.google-services'
repositories {
    google()
    ....
}
dependencies {
    implementation "com.google.firebase:firebase-core:11.8.0"
    ....
}

我已经正确生成了 firebase 应用文件:

./app/src/debug/google-services.json
./app/src/release/google-services.json

当我使用./gradlew clean assembleDebug 构建时,构建失败并出现以下错误:

> Task :app:processDebugGoogleServices FAILED
Found com.google.firebase:firebase-core:11.8.0, but version 11.4.2 is needed for the google-services plugin.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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.

【问题讨论】:

    标签: android firebase gradle google-play-services gradle-plugin


    【解决方案1】:

    解决方案是将此行移至应用程序build.gradle 文件的底部(不应位于顶部):

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

    这是在文档中指定的:

    https://firebase.google.com/docs/android/setup

    然后,在你的模块 Gradle 文件(通常是 app/build.gradle)中,添加 文件底部的应用插件行以启用 Gradle 插件:

    apply plugin: 'com.android.application'
    
    android {
      // ...
    }
    
    dependencies {
      // ...
      compile 'com.google.firebase:firebase-core:11.8.0'
    
      // Getting a "Could not find" error? Make sure you have
      // added the Google maven respository to your root build.gradle
    }
    
    // ADD THIS AT THE BOTTOM
    apply plugin: 'com.google.gms.google-services'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-06
      • 1970-01-01
      • 1970-01-01
      • 2018-11-19
      • 2019-07-20
      • 2018-01-12
      相关资源
      最近更新 更多