Cannot build app with Gradle with flavors and com.google.gms.google-services plugin

99封情书 提交于 2019-12-24 10:50:05

问题


When i try to compile my app with flavors based on minSdk i receive an error:

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 10.2.0.

I pasted example from Android Developers Blog and it's not working.

project 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.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

app gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    defaultConfig {
        applicationId 'pl.net.szafraniec.testApp'
        minSdkVersion 10
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        legacy {
            minSdkVersion 9
            versionCode 901  // Min API level 9, v01
        }
        current {
            minSdkVersion 14
            versionCode 1401  // Min API level 14, v01
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    legacyCompile 'com.google.android.gms:play-services:10.0.0'
    currentCompile 'com.google.android.gms:play-services:10.2.0'
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'
    testCompile 'junit:junit:4.12'
    compile 'com.f2prateek.ln:ln:1.1.1'
}
apply plugin: 'com.google.gms.google-services'

回答1:


One workaround for this issue is to put the apply plugin: 'com.google.gms.google-services' line below your dependencies block which allows the plugin to determine what version of Play services you are using. Since you've already done that, try to download Google Support Repository. You can find it in Tools -> Android -> SDK Manager -> SDK Tools.

You may also check the answers in this related SO post: Google Play Services GCM 9.2.0 asks to "update" back to 9.0.0



来源:https://stackoverflow.com/questions/42693614/cannot-build-app-with-gradle-with-flavors-and-com-google-gms-google-services-plu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!