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\',
Add this line in the dependencies
section of your build.gradle
file:
compile 'com.google.android.gms:play-services:3.2.+'
You don't need to add a .jar
to your libs
folder.
Edit
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.
This didn't work for me, I had to download the Goople Repository in the Android SDK Manager - Extras, to fix it.
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.
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 'com.google.android.gms:play-services-maps:9.8.0'
if you wish to include other services, please refer here:
https://developers.google.com/android/guides/setup (scroll down)
Add this line to your app gradle in dependency block
implementation 'com.google.android.gms:play-services-maps:15.0.1'
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 'com.google.android.gms:play-services:9.6.83'
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.