3

Moving to Android Studio, I'm no more able to add and use the Google Play Servies Library.

I create a simple project, I add the library as module, the sign-in button in my layout but when I run the app crashes because of ClassNotFoundException...

Anyone with the same problem?

fasteque
  • 4,309
  • 8
  • 38
  • 50
  • 1
    Ended up adding the .jar as a Library so I'm now able to use it. – fasteque May 20 '13 at 18:42
  • try this: http://stackoverflow.com/questions/16596715/how-can-i-create-an-android-application-in-android-studio-that-uses-the-google-m – lucasddaniel May 26 '13 at 04:00
  • 1
    If you come here looking for a solution, please do not add the Google Play Services Library as a .jar as I've suggested here above. In Android Studio is now possible to use the official Maven repository as explained here: https://plus.google.com/+AndroidDevelopers/posts/4Yhpn6p9icf – fasteque Jul 23 '13 at 09:57

1 Answers1

0

After two years I created this question a lot of things has changed concerning Android Studio and what you have to do to use the Google Play Services library. I think I can answer myself reporting the important steps of the official documentation which can be found here: https://developers.google.com/android/guides/setup

I also assume you already have installed an updated version of Android Studio with the latest SDK Tools.

So here is the procedure:

1 - Add the required SDK packages from the SDK Manager:

  • Google Repository
  • Google Play services

Official documentation can be found here: https://developer.android.com/sdk/installing/adding-packages.html

2 - Open the build.gradle file inside your application module directory and add a new build rule under dependencies for the latest version of play-services. For example:

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

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

Be sure you update this version number each time Google Play services is updated.

3 - Save the changes and click Sync Project with Gradle Files in the toolbar.

From version 6.5, you can selectively compile Google Play service APIs into your app. In the official documentation you can find the complete list of the individual APIs and corresponding build.gradle descriptions.

Package summary: https://developers.google.com/android/reference/com/google/android/gms/package-summary

When you create a new project, Android Studio also provides a Google Play Services Activity template.

fasteque
  • 4,309
  • 8
  • 38
  • 50