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

1

1

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'
Biotite answered 9/3, 2017 at 11:1 Comment(7)
is any of the dependencies (e.g. 'com.f2prateek.ln:ln:1.1.1') using a different version?Ferrol
download json file and paste into app folderAkkerman
@KarthikSridharan I have json file already in app folder.Biotite
@Ferrol nope, without ln problem still exists.Biotite
Link to my project at current state github.com/mateusz-szafraniec/TestApp/tree/testingBiotite
@Biotite Did you find a solution?Literati
@Literati nope, but i abandonned branch <14Biotite
B
0

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

Biophysics answered 10/3, 2017 at 9:20 Comment(1)
I have latest Google Support Repository already. Problem still exists...Biotite

© 2022 - 2024 — McMap. All rights reserved.