【问题标题】:Error: fix the version conflict (google-services plugin) using productFlavors错误:使用 productFlavors 修复版本冲突(google-services 插件)
【发布时间】:2018-03-04 06:56:28
【问题描述】:

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

错误:任务执行失败 ':app:processCurrentDebugGoogleServices'。 请通过更新 google-services 插件的版本来修复版本冲突(有关最新版本的信息是 可在 https://bintray.com/android/android-tools/com.google.gms.google-services/) 或将 com.google.android.gms 的版本更新为 11.4.0。

我的build.gradle(模块: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
}


现在需要进行哪些更改?

谢谢,

【问题讨论】:

  • 您能否也显示您的根级 build.gradle 文件。它应该有类似的东西: dependencies { classpath 'com.android.tools.build:gradle:3.0.0-beta6' classpath 'com.google.gms:google-services:3.0.0'
  • 好的,我修改了我的问题,谢谢

标签: android firebase gradle google-play-services


【解决方案1】:

较新版本的插件与 Play Services/Firebase 依赖项之间存在冲突。

您不能为不同的产品风格应用同一插件的不同版本,因此在尝试使用不同风格的不同 Play Services 依赖项时会遇到这种冲突。

你可以:

【讨论】:

    【解决方案2】:

    你应该删除该行

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

    因为应用插件:'com.android.application' 已经有相同的包了。

    这就是冲突发生的地方。

    【讨论】:

    • @GowthamanM 您在哪里阅读了这些信息?在此处查看官方指南。 developers.google.com/android/guides/google-services-plugin
    • 检查是否同时添加apply plugin: 'com.android.application'apply plugin: 'com.google.gms.google-services'会出现冲突。
    • @Gowthaman M 这不是最好的答案,有问题!无论如何谢谢。
    【解决方案3】:

    真正的解决方案就是移动

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

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

    【讨论】:

    • 你能详细说明一下吗?这实际上解决了我的构建问题,但我不明白为什么......
    • 这是一个很好的问题,没有人能回答。我认为它必须与引用尚未创建的依赖项有关。就像在声明变量之前调用它。
    猜你喜欢
    • 2018-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多