Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I match a Google Play Services revision with an install version?

Android SDK Manager notified me this morning that there was a new Google Play Services release to download: revision 18. So how do I find the corresponding long version number to put in my build.gradle file? All my test devices are running version 5.0.84, so I tried updating

compile 'com.google.android.gms:play-services:4.4.52'

to

compile 'com.google.android.gms:play-services:5.0.84'

But that resulted in an error:

Gradle 'MyApp' project refresh failed: Could not find com.google.android.gms:play-services:5.0.84. Required by: {my app} Gradle settings

I'm running Android Studio 0.5.2 and building for API19 (I haven't upgraded to Android L/API20 yet): maybe that's the issue? But in general, how do you match a revision number shown in SDK Manager (e.g. 18) with a version code for build.gradle (e.g. 5.0.84)?

Here's my full build.gradle in case it helps:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    // Avoid "Duplicate files copied in APK" errors when using Jackson
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    // Was "compile 'com.android.support:support-v4:+'" but this caused build errors when L SDK released
    compile 'com.android.support:support-v4:19.1.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // Support for Google Cloud Messaging
    // Was "compile 'com.android.support:appcompat-v7:+'" but this caused build errors when L SDK released
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.google.android.gms:play-services:5.0.84'

    // Jackson
    compile 'com.fasterxml.jackson.core:jackson-core:2.3.3'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.3.3'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.3.3'
}
like image 565
Mark Whitaker Avatar asked Jul 03 '14 07:07

Mark Whitaker


People also ask

What does Google Play Services updating mean?

Google Play Services let your Android apps connect to the internet and communicate with Google. Updating Google Play Services can fix app issues, and help your Android device run faster. If updating Google Play Services doesn't help, you can also clear its cache and data.

Which version of Google Play Services do I need?

To test your app when using Google Play services, you must use one of the following: A compatible Android device that runs Android 4.4 (API level 19) or higher and has the Google Play Store app installed.

Can you reinstall Google Play Services?

While not all Android phones come with Google Play installed, you can still install it if you need its service. Generally, Google Play Services is preinstalled on all Android phones.


2 Answers

OK, I haven't quite managed to find a mapping of one to the other, but I've managed the next best thing which is to see a list of Play Services long version numbers installed on my development machine.

For Windows, it's in [android-sdk]\extras\google\m2repository\com\google\android\gms\play-services (where [android-sdk] is the path to your Android SDK folder).

On a Mac, it's inside the Android.app package: browse to sdk/extras/google/m2repository/com/google/android/gms/play-services

The latest version on my machine was 5.0.77 (not 5.0.84), and putting that in my build.gradle worked fine.

Here's the kind of thing you should see at that location:

Google Play Services versions on Windows

Google Play Services versions on OSX

like image 81
Mark Whitaker Avatar answered Oct 23 '22 11:10

Mark Whitaker


What I did in my project was download google play service and open the project structure > dependencies tab and click on the plus button and choose google play service. I dont have to care about the version anymore

like image 3
Jamie Nhu Avatar answered Oct 23 '22 11:10

Jamie Nhu