197

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 here) or updating the version of com.google.android.gms to 8.3.0.

I've done all the things I've found.

  dependencies {
            // This does not break the build when Android Studio is missing the JRebel for Android plugin.
            classpath 'com.zeroturnaround.jrebel.android:jr-android-gradle:1.0.+'
            classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
            classpath 'com.google.gms:google-services:2.0.0-alpha3'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }

And in the app gradle

    compile 'com.google.android.gms:play-services:8.4.0'
Emzor
  • 1,380
  • 17
  • 28
dothem
  • 1,993
  • 2
  • 10
  • 5

14 Answers14

337

Use these dependencies for the project build.gradle

dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
    classpath 'com.google.gms:google-services:2.0.0-alpha3'
}

and put this at the end of the app-level build.gradle file (after the dependencies).

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

I have no clue why putting this at the end (and not at the beginning ) solves the error.

EDIT 5/1/2016

Ok… So trying to put an end to all problems you guys have faced with my solution

This is my final app level gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "your-app-name"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    jcenter()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:design:23.1.1'
    compile 'com.mcxiaoke.volley:library:1.0.6@aar'
}

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

and this is my final project level 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.0.0-alpha3'
        classpath 'com.google.gms:google-services:2.0.0-alpha3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Compare this with your own gradle files, and add or modify any values which are different from what I've written.

sarasgupta
  • 3,472
  • 1
  • 12
  • 13
  • 4
    `compile 'com.google.android.gms:play-services-auth:8.4.0` will also be required. – Shajeel Afzal Dec 25 '15 at 12:42
  • 1
    You also need to make sure you're using Gradle 2.8 (update your gradle-wrapper.properties file). – Andrew Kelly Dec 30 '15 at 02:48
  • 2
    I always wonder how people stumble on solutions like this. Trial and error? Holy scrolls? – A. Steenbergen Jan 02 '16 at 13:08
  • 77
    Why would putting that `apply plugin: 'com.google.gms.google-services'` at the end of the build.gradle file work and putting it at the beginnging fails? – Etienne Lawlor Jan 03 '16 at 21:11
  • 8
    None of the above solutions work for me for 8.4.0. All fail after 2nd 'Rebuild project' I execute after saving build.gradle. The 1st build works (or does not fail loudly), the second gives error about 8.3.0 vs 8.4.0. Using 'com.google.android.gms:play-services' instead of individuals failed. Using (` classpath 'com.google.gms:google-services:2.0.0-alpha3'`) failed with other error (on 2nd build), so I use 1.5.0. Using non Studio Preview did not make a difference. – arberg Jan 04 '16 at 12:36
  • 5
    **IMPORTANT** Don't forget to add your google-services.json file! otherwise it will fail with the message "File google-services.json is missing from module root folder". You can create the file here: https://developers.google.com/analytics/devguides/collection/android/v4/ And as the docs say, next you will add this file to projectFolder/app (so the root of your app-module). – Martin Pfeffer Jan 09 '16 at 20:22
  • 1
    Why add alpha versions of the google services plugin to gradle? – lagos Jan 20 '16 at 08:22
  • Thanks. I had no luck with 2.0.0-alpha6 (the latest version at the moment), but it works fine if I switch back to alpha3. – Aron Lorincz Jan 20 '16 at 20:11
  • Does anyone else have their push notifications broken after this? – davidchuyaya Jan 20 '16 at 22:52
  • 1
    Why Android Studio 1.5.1, doesn't want ``classpath 'com.android.tools.build:gradle:2.0.0-alpha3`` and complains about an ``ANDROID_DAILY_OVERRIDE`` env var? I'm using Graddle 2.10. Anyway, it works with ``com.android.tools.build:gradle:1.5.0`` !?! – fralbo Jan 21 '16 at 16:07
  • 1
    After a full clean and rebuild, this started working. – Tom Jan 25 '16 at 21:20
  • Placing it at the bottom of the file not only saved me from version conflicts, it also got rid of the error message "app:transformClassesWithInstantRunVerifierForDebug" I've been facing since referencing analytics in the code. – Zackline Jan 27 '16 at 16:54
  • 2
    Only thing that worked for me was to switch back to 8.3.0. Tried all other suggestions but nothing worked. – theblitz Jan 31 '16 at 15:42
  • @toobsco42 probably because gradle need to check compile dependencies to find out the gms version what you using before validate the plugin. But yeah: the error messages doesn't help, as usual. – Renascienza Jan 31 '16 at 22:33
  • 2
    What? How? Why? "I have no clue why putting this at the end (and not at the beginning ) solves the error." :o This actually solved it, thanks a lot! :) – yahya Feb 24 '16 at 08:33
  • I tried almost all of other stuffs but in vain. This solution **ONLY** worked! That the Google's official description about setting up Analytics doesn't mention this is fault. – hata Mar 05 '16 at 17:22
  • I had to build via console or invalidate the caches in Android Studio to resolve problems with other dependencies (fabric in my case) afterwards. But now it's working. – JacksOnF1re Mar 09 '16 at 19:14
  • this means, we should use the unstable 'com.android.tools.build:gradle:2.0.0-alpha3' in order to use compile 'com.google.android.gms:play-services-auth:8.4.0' compile 'com.google.android.gms:play-services-maps:8.4.0' compile 'com.google.android.gms:play-services-location:8.4.0' right? If yes i think i would pass, too many bugs for the new gradle build system – HendraWD Mar 10 '16 at 10:38
  • oh... no need to use the new gradle, we can use 1.5.0 but must change the position of apply plugin: 'com.google.gms.google-services' at the end – HendraWD Mar 10 '16 at 10:40
  • 2
    just putting "plugin: 'com.google.gms.google-services' at the end works" for me. – early Mar 21 '16 at 16:16
  • The only thing that was different for me was the **plugin at the end**. Voodoo. (tested with 2.1.0-alpha5) – Amir Uval Apr 01 '16 at 23:03
  • Tried this at IntelliJ with other dependencies among which was `'com.google.android.gms:play-services-gcm:+'`, had to change it to `'com.google.android.gms:play-services-gcm:8.4.0'` because build failed with **very** not coder-friendly error `Error:(49, 0) For input string: "+" `. Beware. – Poliakoff May 14 '16 at 04:32
  • 1
    Seems google likes your solution too: https://github.com/googlesamples/google-services/blob/master/android/signin/app/build.gradle @MatthewCawley (broken link fixed). :) – theapache64 Jul 26 '16 at 15:41
  • but using compile 'com.google.android.gms:play-services:8.4.0' as a whole is not advisable just use the specific sdk you want to use for this case may be compile 'com.google.android.gms:play-services-location:8.4.0' 'com.google.android.gms:play-services-auth:8.4.0' etc – Nasz Njoka Sr. Aug 22 '16 at 21:24
  • 2
    @toobsco42 for anyone wondering why moving the `apply plugin:...` line to the end works, it's [**because of this:**](https://developers.google.com/android/guides/google-services-plugin) _"This step requires that the apply plugin: 'com.google.gms.google-services' line be at the bottom of your app/build.gradle file so that no dependency collisions are introduced. You can see the result of this step by running ./gradlew :app:dependencies."_ – Tony Chan Sep 13 '16 at 00:40
  • For whatever reason, make sure you add the play-services dependency at the top of all your dependencies. It might not work if it is the bottom dependency – Linxy Oct 22 '16 at 16:28
63

In the application's module (build.gradle)

Moving :

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

to the last line solved the issue.

Knight
  • 679
  • 5
  • 3
  • 3
    for anyone wondering why moving the `apply plugin:...` line to the end works, it's [**because of this:**](https://developers.google.com/android/guides/google-services-plugin) _"This step requires that the apply plugin: 'com.google.gms.google-services' line be at the bottom of your app/build.gradle file so that no dependency collisions are introduced. You can see the result of this step by running ./gradlew :app:dependencies."_ – Tony Chan Sep 13 '16 at 00:41
15

Do the following:

  1. Put the following in your build.gradle(Application level gradle file)

    dependencies {
          classpath 'com.android.tools.build:gradle:2.0.0-beta2'
          classpath 'com.google.gms:google-services:2.0.0-beta2'
    }
    

Please check here for latest version as this keep on changing.

  1. If you get the below error message than you need to upgrade your gradle wrapper to latest in gradle-wrapper.properties. I'm using 2.10.

Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable

  1. Put the following line at the bottom of your build.gradle(module level gradle file)

    apply plugin: 'com.google.gms.google-services
    
Muhammed Refaat
  • 8,914
  • 14
  • 83
  • 118
mthakuri
  • 1,085
  • 8
  • 13
  • 1
    Adding the apply plugin line at the BOTTOM of my build.gradle fixed it for me. Thanks! – Panda4Man Mar 21 '16 at 16:10
  • Glad you specified to check the link for the latest version. None of the beta suffixed versions were working for me and I had no idea where people were getting all these versions from. 2.12 finally worked for me. – Ryan H. Jul 07 '16 at 20:57
7

This seems to be fixed with version 3.0.0 of Google Services plugin (and version 9.0.0 of the Google Play Services library). So with this

top level build.gradle

dependencies {
    classpath 'com.google.gms:google-services:3.0.0'
}

app level build.gradle

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

dependencies {
    compile 'com.google.android.gms:play-services:9.0.0
}

Quick Side Note: If you are updating to version 3.0.0 of the google-services plugin, make sure to regenerate your configuration file as it has new fields (explained here).

Edit (2016-06-20): While this does compile and run, I just noticed that in the build logs it does specify to put the plugin at the bottom of the file, or the default (9.0.0) will be used. So in the situation above this isn't a problem since I am using version 9.0.0, but this can be problematic when updating the dependency. Here's the log:

google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used. please apply google-services plugin at the bottom of the build file.

jguerinet
  • 1,429
  • 1
  • 14
  • 21
5

For me works only this:

Top level.

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.google.gms:google-services:3.0.0'
}

App level:

dependencies {
    compile 'com.google.android.gms:play-services-gcm:9.0.1'
    compile 'com.google.android.gms:play-services-location:9.0.1'
}

// should be at the bottom
apply plugin: 'com.google.gms.google-services'
DeniSHow
  • 1,394
  • 1
  • 18
  • 30
4

found in official example

in 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.0.0-alpha9'
        classpath 'com.google.gms:google-services:2.0.0-alpha9'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

in app gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.google.samples.quickstart.signin"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'LICENSE.txt'
    }

    // Resolve dependency differences between app and tests
    configurations.all {
        resolutionStrategy.force 'com.android.support:support-annotations:23.1.1'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'

    // Dependency for Google Sign-In
    compile 'com.google.android.gms:play-services-auth:8.4.0'

    // UiAutomatorTesting
    androidTestCompile 'com.android.support.test:runner:0.4.1'
    androidTestCompile 'com.android.support.test:rules:0.4.1'
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
    androidTestCompile 'com.android.support:support-annotations:23.1.1'
}

apply plugin: 'com.google.gms.google-services'
Peter Kao
  • 79
  • 3
  • 1
    To use `alpha9` worked for me with `Gradle 2.11`. Thank you for this! Can you please link to the official example maybe it is also helpfull for other problems like this. – Cilenco Feb 11 '16 at 11:17
  • 1
    [Official example](https://developers.google.com/identity/sign-in/android/start?hl=zh-tw) – Peter Kao Mar 01 '16 at 06:19
2

I have updated in app build.gradle

dependencies {
....
compile 'com.google.android.gms:play-services-auth:9.0.0'

and app build.gradle

  dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath 'com.google.gms:google-services:3.0.0'
}

Its working for.

Raja Peela
  • 1,366
  • 2
  • 14
  • 26
2

In my caseI have removed the "apply plugin: 'com.google.gms.google-services'" from the end of the gradle.build and its working fine.

Rick Smith
  • 9,031
  • 15
  • 81
  • 85
Chirag Thummar
  • 665
  • 6
  • 16
1

The important thing is to set Gradle to Version 2.10

https://stackoverflow.com/a/35188079/570168

Community
  • 1
  • 1
Tobias
  • 7,282
  • 6
  • 63
  • 85
1

I Was serching... at the Google page there is the solution...https://developers.google.com/android/guides/google-services-plugin#introduction

Add dependencies for basic libraries required for the services you have enabled. This step requires that the apply plugin: 'com.google.gms.google-services' line be at the end of your app/build.gradle file so that no dependency collisions are introduced. You can see the result of this step by running ./gradlew :app:dependencies.

1

There is no meaning in moving apply plugin: 'com.google.gms.google-services' to the end of build.gradle. It is same as not defining it.

Just remove this line and make sure apply plugin: 'com.android.application' is there

Use:

compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services:8.4.0'

it will compile.

ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
Goku
  • 21
  • 1
  • 4
  • Applying the plugin does/could have an effect on which version is used. See this [answer by rguerinet](http://stackoverflow.com/a/37331930/305383) – Ryan H. Jul 10 '16 at 13:23
0

In project gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:2.0.0-alpha6'
    }
}

in app/module gradle

apply plugin: 'com.google.gms.google-services'
android {
    ...
}

dependencies {
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
}
Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98
-1

In project gradle:

       compileSdkVersion 23

It is working.

nocmmnt
  • 3
  • 6
-3

Here is my instruction to fix it.

  1. Change to use compile 'com.google.android.gms:play-services-location:8.3.0' in app build.gradle
  2. Move apply plugin: 'com.google.gms.google-services' to the end of app build.gradle
  3. Use classpath 'com.google.gms:google-services:2.0.0-alpha3' in project build.gradle dependency
  4. Change to use gradle-2.8 in gradle/wrapper/gradle-wrapper.properties
Tunaki
  • 132,869
  • 46
  • 340
  • 423
hawa11
  • 481
  • 5
  • 5