Add Google Play Services to Android Studio using Gradle-ThrowExceptions

Exception or error:

Im working on simple map app, I added google-play-services.jar and its reference to gradle

dependencies {
    compile files('libs/android-support-v4.jar', 'libs/google-play-services.jar')

The main activity:


GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(;

layout file

<fragment xmlns:android=""

But the app crashes on the device

E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError:$styleable at
Source) at

I tried several ways, same issue, I just want to add google services to Android Studio 0.3 with Gradle 0.6+

How to solve:

As @Matt said, it is correct, I am here covered also which I did not find in the answer.

To add the Google Play Service library in your application project, follow below steps :-

1) Open the build.gradle file of your application module directory. See screenshot


2) Add new in your dependecies, here you to update the version number whenever you update the Google Play Service.

dependencies {
    compile ''
    compile files('src/main/libs/gson-2.2.4.jar')


3) Now Lastly important save your file and click on Sync with Gradle Files Iconin the toolbar.


Add this line in the dependencies section of your build.gradle file:

compile ''

You don’t need to add a .jar to your libs folder.


As Varun pointed out, you also need to update the SDK to contain the most recent version of the play services.

You can do this by opening up the Android SDK Manager (under the Window tab) from Eclipse+ADT, checking the box next to Google Play services in the Extras folder, and clicking install.


enter image description here

enter image description here

Hit check on all tools, to be safe

enter image description here

Hit check on API you are working with

enter image description here

Hit check on all extras to be safe

enter image description here

Go to file -> project structure

enter image description here

enter image description here

enter image description here

Finally go to build at the top of the screen and hit rebuild project


This didn’t work for me, I had to download the Goople Repository in the Android SDK Manager – Extras, to fix it.


Try to avoid including entire google play services, when you use more library then you get Multidex exception:

The number of method references in a .dex file cannot exceed 64k

So best way to use:

compile ''

if you wish to include other services, please refer here: (scroll down)


Go to Android SDK Manager, go to Extras, select Google Play Services and Google Repository and then click on ‘Install Packages…’ button.

Click on ‘build.gradle’ file, in the code window in editor, then click on ‘try again’ link button…

Wait until gradle build finish.


Go to the setting -> apps in your android testing phone and search for google play services and click on it, there you will find the version number installed on your device.

For me it was 9.6.83

then just add your version number to this command below :-

compile ‘’

  • Add this to you build.gradle(app)

  • Gradle sync

Later you may get a gradle error saying that the particular repository needs to be installed, Go ahead and download it ! Voila your next gradle sync is successfull.


Add this line to your app gradle
in dependency block

implementation ‘’

Leave a Reply

Your email address will not be published. Required fields are marked *