2

I need to get ConnectionResult.SUCCESS when I'm checking Google Play Services availability if installed Google Play Services version is 4.1+:

int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

Currently I'm geting code == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED, when Google Play Services version is 5.0.84.

I know that all i need is to add some tag to manifest witch should include GooglePlayServices version code. But i do not know witch one and what version number belong to 4.1. Please advice.

Vitaliy A
  • 3,651
  • 1
  • 32
  • 34

2 Answers2

7

This is what i found till now:

No need to do any changes on manifest file.

Version code for Google Play Services is 7 digits number and its complicated from same digits as version name.

For example:

version 4.1.00 has code 4100000 version 6.5.99 has code 6599000

So, when i need to check if installed GooglePlayServices is updated enough i do:

int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    ...
    if (code == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED) {
        if (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= 4100000)
            result = true;// Meets minimum version requirements
    }
Vitaliy A
  • 3,651
  • 1
  • 32
  • 34
  • How can u get the minimum version required for your app (in your case it's 4100000)? – Wayne Feb 07 '15 at 18:42
  • When i check if google play services available at all and recive code ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED all i need to check if existing google play services is meet minimum expected version, so i check GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE value. When it is too old I can show to user warring about it and restrict app usage until user gets last updated google play services version. – Vitaliy A Feb 08 '15 at 15:36
  • I meant how do you get the number 4100000? My app use many GPS features and I don't know what the minimum version required to run all of those features. – Wayne Feb 09 '15 at 03:00
  • btw your code is wrong because GOOGLE_PLAY_SERVICES_VERSION_CODE is version of your GPS library declare in your manifest, not on device. – Wayne Feb 09 '15 at 03:24
  • Wayne: you right about GOOGLE_PLAY_SERVICES_VERSION_CODE but it is not related to my project AndroidManifest, it is related to GPS library project itself witch include its own manifest file. About exact minimum version: In my project I'm using Ads with DFP support, witch is available starting from GPS version 4.1. Every future and info about minimum required version you can find here: http://developer.android.com/reference/gms-packages.html – Vitaliy A Feb 09 '15 at 10:26
0

If you need to support GMS back to 4.1 you need to include the following dependency

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

Alternatively extract <android-sdk>\extras\google\m2repository\com\google\android\gms\play-services\4.1.32\play-services-4.1.32.aar and import it as a library project if you're using Eclipse.

This will add the GMS interface library of version 4.1.32 to your project. This also means you have to use older APIs (before unified GoogleApiClient).

Eugen Pechanec
  • 37,669
  • 7
  • 103
  • 124