Android Studio with Google Play Services

All those answers are wrong, since the release of gradle plugin v0.4.2 the setup of google play services under android studio is straight forward. You don’t need to import any jar or add any project library nor add any new module under android studio. What you have to do is to add the correct dependencies into the build.gradle file. Please take a look to those links: Gradle plugin v0.4.2 update, New Build System, and this sample

The Correct way to do so is as follows:

First of all you have to launch the sdk manager and download and install the following files located under “extras”: Android support repository, Google play services, Google repository.

Restart android studio and open the build gradle file. You must modify your build.gradle file to look like this under dependencies:

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

And finally syncronise your project (the button to the left of the AVD manager).

Since version 6.5 you can include the complete library (very large) or just the modules that you need (Best Option). I.e if you only need Google Maps and Analytics you can replace the previous example with the following one:

dependencies {  
    compile 'com.google.android.gms:play-services-base:6.5.87'    
    compile 'com.google.android.gms:play-services-maps:6.5.87'  
}

You can find the complete dependency list here

Some side notes:

  • Use the latest play services library version. If it’s an old version, android studio will highlight it. As of today (February 5th is 6.5.87) but you can check the latest version at Gradle Please
  • After a major update of Android Studio, clean an rebuild your project by following the next instructions as suggested in the comments by @user123321

    cd to your project folder
    ./gradlew clean
    ./gradlew build

Leave a Comment