51

I get an error saying

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

I tried looking at https://bintray.com/android/android-tools/com.google.gms.google-services/ and com.google.gms:google-services:3.0.0 seems to be the latest. This is my project gradle

dependencies {
            classpath 'com.android.tools.build:gradle:2.1.2'
            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
        }

And this is how my app gradle looks like

buildscript {
        repositories {
            maven { url 'https://maven.fabric.io/public' }
        }

        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }
    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    apply plugin: 'com.google.gms.google-services'

    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }


    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.1"
        useLibrary 'org.apache.http.legacy'

        defaultConfig {
            applicationId "com.myapp.preburn"
            minSdkVersion 10
            targetSdkVersion 24
            versionCode 14
            versionName "2.0.1"
            renderscriptTargetApi 22
            renderscriptSupportModeEnabled true
        }
        buildTypes {
            release {
                lintOptions {
                    disable 'MissingTranslation'
                }
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    android {
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
        }
    }

    repositories {
        mavenCentral()
        jcenter()
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile fileTree(dir: 'libs', include: 'Parse-*.jar')
        compile 'com.parse.bolts:bolts-android:1.2.0'
        compile 'com.android.support:appcompat-v7:24.1.1'
        compile 'com.mcxiaoke.volley:library:1.0.9'
        compile 'com.google.android.gms:play-services-gcm:9.4.0'
        compile 'com.google.android.gms:play-services-location:9.4.0'
        compile 'com.google.android.gms:play-services-maps:9.4.0'
        compile 'com.google.android.gms:play-services-ads:9.4.0'
        compile 'com.google.android.gms:play-services-plus:9.4.0'
        compile 'com.google.android.gms:play-services-analytics:9.4.0'
        compile 'me.leolin:ShortcutBadger:1.1.3@aar'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile files('libs/jsoup-1.7.3.jar')
        compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
            transitive = true;
        }
        compile files('libs/InMobi-5.2.2.jar')
        compile files('libs/libadapterinmobi.jar')
        compile files('libs/StartAppAdMobMediation-1.0.1.jar')
        compile files('libs/StartAppInApp-3.3.1.jar')
        compile 'org.adw.library:discrete-seekbar:1.0.1'
        compile 'com.pnikosis:materialish-progress:1.0'
    }

If I change the play services to 9.0.0 everything compiles fine. What am I missing here?

tbag
  • 1,268
  • 2
  • 16
  • 34

10 Answers10

149

You need to put the apply plugin: 'com.google.gms.google-services' line below your dependencies block - this allows the plugin to determine what version of Play services you are using.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • 5
    Yeah it works. Just curious, I put apply plugin..... on top of the block and seems like it does not work. Why does it have to be below the block? – Long Dao Aug 09 '16 at 23:37
  • 9
    @LongDao - the file has more in common with a computer program than a config file - it is read and executed in order. By placing the `apply plugin` line before the `dependencies` block, the plugin executes and configures your build before knowing what version of Google Play services you are actually using - it effectively can't 'read ahead' – ianhanniballake Aug 09 '16 at 23:40
  • Oh I see, so order of code actually matter here. Thanks for the explanation. :) – Long Dao Aug 09 '16 at 23:43
  • 3
    I'm getting Error: Plugin with id 'com.google.gms.google-services' not found. Any idea how to solve it? – Anirudh Aug 11 '16 at 05:43
  • 1
    @Anirudh - that sounds like a different question entirely – ianhanniballake Aug 11 '16 at 05:48
  • https://developers.google.com/analytics/devguides/collection/android/v4/?configured=true I wander why this is not mentioned in the official tutorial – SpyZip Aug 19 '16 at 07:41
  • @SpyZip - it is clearly stated in the [Google Play services setup docs](https://developers.google.com/android/guides/setup) - step 2 – ianhanniballake Aug 19 '16 at 13:56
  • Doc for the plugin setup has moved here: https://developers.google.com/android/guides/google-services-plugin – albert c braun May 01 '17 at 23:49
62

If you have firebase dependencies. Update their version to match version of google services: Example:

 //Firebase Crashreports
 compile 'com.google.firebase:firebase-crash:9.6.1'
//Firebase Analytics
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.android.gms:play-services-gcm:9.6.1'

All must have same 9.6.1 version

i_tanova
  • 667
  • 4
  • 5
  • this worked for me, even though in the docs google play services use 9.8.0, you have to MATCH version with firebase dependencies. – aldok Oct 26 '16 at 04:30
  • 1
    Thanks to your answer. noticed that the version of all play-services and firebase-crash should match.(9.4.0 in my case) – onexf Oct 27 '16 at 10:56
  • Hi guys ! Every time I move from 9.8.0 to 9.6.1 after lauching it comes back to 9.8.0 ... Any idea ? Would be really cool ! :D – luiswill Apr 24 '17 at 16:35
3

just write this after dependencies

apply plugin: 'com.google.gms.google-services'
Mor2
  • 101
  • 1
  • 1
1

Do you have the line

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

line in the end of you build.gradle file?

This error came mostly when "apply plugin" put at the top.

Er. Joshi
  • 185
  • 1
  • 8
1

I run into the same problem.

My solution was not to add anything to the code but download Google Support Repository - you can find it in Tools -> Android -> SDK Manager -> SDK Tools

Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
mr0
  • 43
  • 1
  • 6
1

Just apply the google-services below the dependencies. worked for me.

Mwongera808
  • 880
  • 11
  • 16
1

I was facing similar problem.At the top when the plugin is added it did not work for me.so Add the plugin at the bottom of the gradle. this solve my problem of conflict Version

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

and add it dependency these lines

 compile 'com.google.firebase:firebase-core:9.2.0' 
 compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.android.gms:play-services-places:9.2.0'
Mudassir Khan
  • 1,714
  • 1
  • 20
  • 25
0

I installed Google Repository:

Android > SDK Manager. Update the Android Studio SDK Manager: click SDK Tools, expand Support Repository, select Google Repository, and then click OK.

Fabio Campinho
  • 982
  • 8
  • 13
-1

Just go to /platforms/android/cordova-plugin-fcm/*-FCMPlugin.gradle

find for

classpath 'com.google.gms:google-services:+'

replace it with

classpath 'com.google.gms:google-services:3.0.0'

build again.

Kapilrc
  • 1,362
  • 15
  • 11
-1

This is problem is actually take my lot of time, however I solved it by applying the plugin com.google.gms.google-services.

Important: Make sure to don't use it at the top of the gradle file, and use it after the block of dependencies.

clemens
  • 16,716
  • 11
  • 50
  • 65
Abhishek Garg
  • 3,092
  • 26
  • 30