1
votes

I'm getting an error when I'm trying to add the classpath to google play services in my root build.gradle file. I'm trying to follow a firebase tutorial and it states to put classpath 'com.google.gms:play-services:11.0.4'into the root gradle file

buildscript {
     repositories {
     jcenter()
}
     dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:play-services:11.0.4'
    // NOTE: Do not place your application dependencies here; they 
    belong
    // in the individual module build.gradle files
}
}

However, I'm getting the following error:

Error:Could not find com.google.gms:play-services:11.0.4.
Searched in the following locations:
file:/home/graffixnyc/android-studio/gradle/m2repository/com/google/gms/play-services/11.0.4/play-services-11.0.4.pom
file:/home/graffixnyc/android-studio/gradle/m2repository/com/google/gms/play-services/11.0.4/play-services-11.0.4.jar
https://jcenter.bintray.com/com/google/gms/play-services/11.0.4/play-services-11.0.4.pom
https://jcenter.bintray.com/com/google/gms/play-services/11.0.4/play-services-11.0.4.jar
Required by:
project :

Now what I noticed is it's looking in /home/graffixnyc/android-studio/gradle/m2repository/com/google/gms/play-services/11.0.4/play-services-11.0.4.pom

However, mine is located: /home/graffixnyc/android-sdk/extras/google/m2repository/com/google/android/gms/play-services/11.0.4

My SDK has always been in this location so I'm not sure why it's looking in /home/graffixnyc/android-studio/gradle/m2repository/com/google/gms/play-services/11.0.4

How do I get Android Studio to recognize it in the correct location?

4

4 Answers

2
votes

You need to change this line of code:

classpath 'com.google.gms:play-services:11.0.4'

with

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

Class path should be google-services not play-services:

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

while:

compile "com.google.gms:play-services:11.0.4"

in the other gradle file.

Webpage for reference(I think firebase same logic):

https://developers.google.com/cloud-messaging/android/client

0
votes

Did you "Save the changes and click Sync Project with Gradle Files in the toolbar." as per the instructions at https://developers.google.com/android/guides/setup ? This has caught me out a few times.

Failing that the official Firebase docs at official Firebase docs are quite good at clarifying which bits go in which Gradle files

0
votes

If what you are looking for is add the google play services instead of all google services you should add this classpath:

apply plugin: 'com.android.application'
    ...

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

The classpath package is com.google.android.gms instead of com.google.gms.

You can found more of information here: https://developers.google.com/android/guides/setup. Hope this helps