Add Google Play Services to Android Studio using Gradle

后端 未结 8 1381
萌比男神i
萌比男神i 2020-12-24 03:23

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\',          


        
相关标签:
8条回答
  • 2020-12-24 03:30

    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.

    0 讨论(0)
  • 2020-12-24 03:31

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

    0 讨论(0)
  • 2020-12-24 03:32

    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.

    0 讨论(0)
  • 2020-12-24 03:37

    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)

    0 讨论(0)
  • 2020-12-24 03:42

    Add this line to your app gradle in dependency block

    implementation 'com.google.android.gms:play-services-maps:15.0.1'

    0 讨论(0)
  • 2020-12-24 03:46

    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.

    0 讨论(0)
提交回复
热议问题