59

I am integrating OAuth login for Google+ on my android application, following the tutorial.

According to the tutorial, I should add the Google Service plugin by adding classpath 'com.google.gms:google-services:1.0' dependency to top-level build.gradle in my android project.

However, when I sync the gradle with the changes, I see the error as follows:

Error:Could not find com.google.gms:google-services:1.0.

Searched in the following locations: file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.pom file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.jar https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.pom https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.jar

In my build.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:1.2.3'
        classpath 'com.google.gms:google-services:1.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

It seems that the android studio is not able to find google-services plugin from repositories.

Does anybody have the same issue? Or, am I missing something?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
makeasy
  • 907
  • 1
  • 6
  • 15

20 Answers20

73

I ran into the same issue today. In the samples they use this line instead: classpath 'com.google.gms:google-services:1.3.0-beta1' This works.

Jonas Lüthke
  • 1,480
  • 10
  • 11
  • 37
    check that you have jcenter() on your repositories in the buildscript. It wasn\t working for me cause I was using mavenCentral() only – Chiara Jun 11 '15 at 08:12
  • 3
    How can we find out when this is updated? e.g. to 1.3.0-final or 1.4.0? – AG1 Aug 31 '15 at 15:47
  • 3
    As mentioned below checkout https://jcenter.bintray.com/com/android/tools/build/gradle/ for the latest version. – Jonas Lüthke Sep 14 '15 at 14:00
  • 5
    Please check the available version at https://bintray.com/android/android-tools/com.google.gms.google-services/view . Please use available version instead provided in tutorial – hutingung Sep 18 '15 at 11:00
  • It's better to import specific APIs, which in this case will be `compile 'com.google.android.gms:play-services-plus:8.1.0'`. It will not import unnecessary APIs of fitness, wearable, maps, etc. You can see the [table 1 on this page](https://developers.google.com/android/guides/setup). – Sufian Oct 06 '15 at 11:32
  • @Chiara Give me your address, so that I can send you a beer. You sure as hell deserve one. – EZFrag Oct 07 '15 at 13:43
50

For me I had to switch the repository to jcenter(). I was using mavenCentral and getting this error. As soon as I switched to jcenter() it pulled the dependency down.

To do this, open your build.gradle and replace each instance of mavenCentral() with jcenter()

exhuma
  • 20,071
  • 12
  • 90
  • 123
Patrick Jackson
  • 18,766
  • 22
  • 81
  • 141
13

Google updated their guide. Where it was classpath 'com.google.gms:google-services:1.0' now reads classpath 'com.google.gms:google-services:1.3.0-beta1' like joluet suggested.

enter image description here

Emzor
  • 1,380
  • 17
  • 28
Rui Santos
  • 537
  • 3
  • 15
10

Google now released the plugin v1.3.0

I was able to solve it using this:

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

Emzor
  • 1,380
  • 17
  • 28
Arslan Anwar
  • 18,746
  • 19
  • 76
  • 105
10

I resolved this issue by doing the following things:

  1. In build.gradle (at project level):

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            mavenCentral()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.3.0'
            classpath 'com.google.gms:google-services:1.5.0-beta2'
         }
    }
    
    allprojects {
        repositories {
            mavenCentral()
        }
    }
    
  2. In build.gradle (at module level):

    On top added:

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

    and in dependecies added:

    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    

Apart from this make sure you have updated the Google Play services and Google repository in the SDK.

Generic Bot
  • 309
  • 1
  • 4
  • 8
Shirish Singh
  • 797
  • 7
  • 17
7

As of 25th Nov,2015, google released a newer version.

Try adding: classpath 'com.google.gms:google-services:2.0.0-alpha1'

And don't forget to add jcenter() repository under buildscript.

Thanks.

driftking9987
  • 1,673
  • 1
  • 32
  • 63
4

I think you forgotten gradle's project level,

From developers page:

Add the dependency to your project-level build.gradle
classpath 'com.google.gms:google-services:1.5.0-beta2'

Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'

MarsPeople
  • 1,772
  • 18
  • 30
4

Google has updated GCM go check it and for that you have to update your Android Studio too.

enter image description here

Pre_hacker
  • 1,352
  • 1
  • 17
  • 21
3

I would advise you against doing what you are doing. I did it too (by following Set up a GCM Client App on Android blindly) but ended up with exceeding 65K method limit.

So, you should remove the following lines from your gradle:

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

Now import APIs of Google Plus with simple gradle import:

compile 'com.google.android.gms:play-services-plus:8.1.0'
Sufian
  • 6,405
  • 16
  • 66
  • 120
3

Adding jcenter repository to project level build.gradle helped in my case:

buildscript {
    repositories {
        jcenter();
        mavenCentral()
    }
Anne
  • 61
  • 2
1

I was trying to setup firebase for my android app when I faced this problem. Following screenshot should clarify things -

enter image description here

Couple of things I would like to point out - 1. Once you

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

This line should be at the bottom of the app level gradle file. Not sure why but putting at the top did not workout for me.

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
1

If you use Android Studio, try to add google service with the IDE.

  1. Right click on folder module.
  2. On left list at Developer Services choose desired service.
  3. Wait for syncing and the IDE will automatically add google dependecies.
  4. add classpath on buildscript

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

Wildan Muhlis
  • 1,553
  • 2
  • 22
  • 43
0

You maybe miss this step

Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project. Open the Android Studio Terminal pane: $ move path-to-download/google-services.json app/

Have fun.

Trung NT Nguyen
  • 403
  • 2
  • 14
  • Thanks for your comment! I do not think Installing google-service plugin does have to do with google-service.json file at this time, as the json file will be loaded AFTER the plugin installed. In other words, I asked about the issue of installing google-service plugin, not loading the configuration file with the plugin. Thanks anyways! – makeasy May 30 '15 at 04:01
0

I got a similar problem while following the instructions for implementing a GCM client in Android Studio, however, the message I got was :

Error: Could not find com.google.gms:google-services:1.3.0-beta1...

Although I never figured out what was wrong, I simply copied my sources, resources, manifest, and keystore into a new Android Studio project. I then edited the auto-generated gradle build files for the new project by manually re-adding my dependencies.

I made sure not to copy over my build files from the old project verbatim (since the source of the error likely lay in them somewhere).

It is not a satisfying solution, but it worked for me and it took little time.

Emzor
  • 1,380
  • 17
  • 28
0

You should just add classpath 'com.google.gms:google-services:1.3.0-beta1' to dependencies of your (Top level build file) the build.gradle that has the (Project:<name of your project). Hope this helps!

Vinoth Vino
  • 9,166
  • 3
  • 66
  • 70
mangu23
  • 884
  • 9
  • 13
0

You need to check the current version as in the link below says, by now:

classpath 'com.google.gms:google-services:1.3.0-beta4'

Check this answer:

Update gradle version

Community
  • 1
  • 1
Anexon
  • 113
  • 1
  • 10
0

We have to look for the last version in my case was:

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

Here you can find a list of the versions.

Emzor
  • 1,380
  • 17
  • 28
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
0

Inside the .idea folder exists a workspace.xml file that defines the project's structure. I suggest you to close Android Studio, then delete .idea folder and then import the project again. The .idea would be generated by the IDE again. For me this solution works.

Vinoth Vino
  • 9,166
  • 3
  • 66
  • 70
Nativ
  • 3,092
  • 6
  • 38
  • 69
0

For me adding this under dependencies worked

compile 'com.google.gms:google-services:3.0.0'
jeet.chanchawat
  • 5,842
  • 5
  • 38
  • 59
0

I recently updated to Android Studio 2.3 and somehow apply plugin doesn't work.

After that, I tried various ways and then what work is when I commented out app's build.gradle:

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

and then I add this to top-level build.gradle (below classpath 'com.android.tools.build:gradle:2.2.3'):

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

and then it works.

Abdul Rahman A Samad
  • 1,062
  • 1
  • 15
  • 21