graffixnyc
graffixnyc

Reputation: 1

Getting an error when adding play services to build.gradle

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?

Upvotes: 1

Views: 1155

Answers (4)

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

Upvotes: 0

CJLWS
CJLWS

Reputation: 21

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

Upvotes: 0

Mohammad Tabbara
Mohammad Tabbara

Reputation: 1467

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

Upvotes: 1

Alex Mamo
Alex Mamo

Reputation: 138824

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'

Upvotes: 2

Related Questions