Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: fix the version conflict (google-services plugin) using productFlavors

I know there are version conflicts, but issue still persists after new versions from 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.

My 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'

My Build.gradle : (Project)

// 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
}


What changes are required now?

Thank you,

like image 483
iLyas Avatar asked Sep 22 '17 16:09

iLyas


3 Answers

The real solution is just to move the

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

at the bottom of the (app)build.gradle script and rebuild the project. Works 100%

like image 115
Darko Bacic Avatar answered Nov 12 '22 12:11

Darko Bacic


The conflict is between a newer version of the plugin and the Play Services/Firebase dependencies.

You cannot apply different versions of the same plugin for different product flavors, thus you will run into this conflict when trying to use different Play Services dependencies in different flavors.

You can:

  • Drop support for the ~1% of users on API levels lower than 14 in new versions of your app
  • Stay on an older Play Services/Firebase version that still supports 14
like image 5
Bryan Herbst Avatar answered Nov 12 '22 12:11

Bryan Herbst


You should delete the line

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

Because apply plugin: 'com.android.application' already has same package.

That's where the conflict arises.

like image 1
Gowthaman M Avatar answered Nov 12 '22 11:11

Gowthaman M