50

Can't use google maps because of above said error. Anyone find the same issue ?

shijin
  • 2,998
  • 1
  • 24
  • 30
  • 4
    Possible duplicate of [Version conflict updating to 8.4.0](http://stackoverflow.com/questions/34370603/version-conflict-updating-to-8-4-0) – yuval Dec 21 '15 at 20:14
  • If you're using for only gmail authentication verify [this](http://stackoverflow.com/questions/34370603/version-conflict-updating-to-8-4-0/38355760#38355760) – Raja Peela Jul 13 '16 at 15:24

9 Answers9

114

Make sure that the following line is at the end of the app build.gradle file:

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

Mine was on the top and gradle was defaulting to 8.3.0 instead of what was specified: 8.4.0

My build.gradle files are the same as the ones in the Version conflict updating to 8.4.0

redochka
  • 12,345
  • 14
  • 66
  • 79
  • 1
    Wow, this works. But is so strange to apply a plugin at the end of the build.gradle file! I haven't seen an example of this anywhere else. – IgorGanapolsky Feb 12 '16 at 17:32
  • 1
    Not only that but notice the plugin itself generates this line if it isnt at the end of the file: "please apply google-services plugin at the bottom of the build file.". Therefore this is the correct solution. – Greg Ennis Mar 31 '16 at 00:16
  • 1
    This works. One of the pleasurable things of working with command line is those error details make sense. AS is a headache when it comes to fixing gradle issues – humblerookie Apr 12 '16 at 07:45
  • @DatNguyen: I think what you're saying is it's more of a kludge than a hack, then. As Raymond Chen might ask, "What if two programs did this?" – Craig Stuntz Apr 19 '16 at 19:33
  • I guess these things can happen once you have stateful build description files. – bompf Jun 13 '16 at 13:12
27

As those previous anweres are only part-wise complete. Here are my three steps which worked fine for me:

  1. Put this to the end of your apps build.gradle

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

  2. Set your projects build.gradle dependencies to

    'classpath 'com.google.gms:google-services:2.0.0-alpha5'

  3. Set Gradle Version to 2.10

    Android Studio: File > Project Structure > Project

Tobias
  • 7,282
  • 6
  • 63
  • 85
20

@redsonic's answer worked for me.. By simply moving apply plugin: 'com.google.gms.google-services' after the dependecies in build.gradle (Module: app)

I'm using Android Studio 1.5.1 with Gradle version 2.10

In case you are using Gradle version older than 2.10 you'll also need to update that by selecting the ProjectName or app directory in the Project tool Windows and pressing F4. This will open Project Structure window, select Project from the menu and update Gradle version to 2.10. Press OK (Android Studio will download it in background).

build.gradle (Project: ProjectName)

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

build.gradle (Module: app)

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:8.4.0'
}

apply plugin: 'com.google.gms.google-services'
Super Android
  • 201
  • 1
  • 2
  • 2
    you must put - apply plugin: 'com.google.gms.google-services' after dependencies block. Otherwise it won't work... – dudego Mar 10 '16 at 09:56
5

This is a slight variant of @Lord Flash's answer:

For me it wasn't necessarily that I should place the google services plugin at the bottom of the file it was that it should come before the com.android.application plugin.

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

Also there are newer binaries than the alpha variants for google-services

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

I'm sure there will be newer ones soon. I found the list of variants here

Greg
  • 5,422
  • 1
  • 27
  • 32
2

follow all the steps at this link Add App Invites to Your App

use this : compile 'com.google.android.gms:play-services-appinvite:8.4.0'

instead of this : compile 'com.google.android.gms:play-services:8.4.0'

please follow all the steps and then build the project

hope thats help

Amer Hadi
  • 277
  • 3
  • 15
2

I had the same problem, and I found that moving:

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

To the bottom of the module app gradle.

and then use:

classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.google.gms:google-services:2.1.0'

Bjqn
  • 146
  • 2
  • 19
0

The problem is that some of your app dependencies that start with com.google.android.gms: have a version that is incompatible your project dependencie classpath 'com.google.gms:google-services:

Check for these on your app build.gradle

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

And for this in your project build.gradle

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

You can update your project build.gradle to use the latest google-services version or your can just change your app dependencies to use the 8.3 version.

Renato Probst
  • 5,914
  • 2
  • 42
  • 45
0
// 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.1.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
}

// this should solve the gradle update error if it persists even after following above steps
0

Make sure that the following line is at the end of the app build.gradle file:

compile 'com.google.android.gms:play-services:11.0.2'

google update there API day by day.Now mine is '11.0.2' try with the updated API