android - 错误 : fix the version conflict (google-services plugin) using productFlavors

标签 android firebase gradle google-play-services

我知道存在版本冲突,但在 Google 推出新版本后问题仍然存在。

Error:Execution failed for task ':app:processCurrentDebugGoogleServices'. 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.0.

我的build.gradle(Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.x.x"
        minSdkVersion 9
        targetSdkVersion 26
        versionCode 10
        versionName "1.1"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    productFlavors {
        legacy {
            minSdkVersion 9

        }
        current {
            minSdkVersion 14
        }
    }

}

    dependencies {
       compile fileTree(dir: 'libs', include: ['*.jar'])
       androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        })
       testCompile 'junit:junit:4.12'

    legacyCompile 'com.google.firebase:firebase-ads:10.0.1'
    legacyCompile 'com.google.firebase:firebase-core:10.0.1'

    currentCompile 'com.google.firebase:firebase-ads:11.4.0'
    currentCompile 'com.google.firebase:firebase-core:11.4.0'
    }

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

我的 Build.gradle :(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.1'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

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


现在需要进行哪些更改?

谢谢,

最佳答案

真正的解决方案只是移动

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

在 (app)build.gradle 脚本的底部并重建项目。工作 100%

关于android - 错误 : fix the version conflict (google-services plugin) using productFlavors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46369055/

相关文章:

ios - facebooksdk 无法快速获取 accesstoken

firebase - 从 firebase 检索时,字符串在离开 child 后返回 null

java - 使用来自 mainClassName 的 gradle 设置 Main-Class header

iphone - 是否可以通过Gradle构建iphone项目?

gradle - 如何将子项目生成的类添加到Gradle中WAR文件的WEB-INF/classes目录中

android - Ormlite连接mysql数据库

java - 如何在点击时翻转 android 对话框?

android - ScrollView 和 ConstraintLayout 在底部留下巨大的空白

android - 在 Android 中使用 Scala 中的 Java 常量

ios - 在 iMessage 扩展中使用 Firebase 时崩溃