21

According to the documentation GooglePlayServicesUtil.isGooglePlayServicesAvailable returns SERVICE_VERSION_UPDATE_REQUIRED when "The installed version of Google Play services is out of date".

Does this mean that there is a new version of google play services in the play store?
Does this mean that the app needs a newer version than the one that is currently installed in the device?

How is this check done?

pomber
  • 23,132
  • 10
  • 81
  • 94

6 Answers6

11

this means that the version of google play service you included in your app is higher than the one currently installed on the users device. the user needs to update their google play services in-order for your app to work correctly.

if the result comes back with that error you can simply call this method to alert the user they need to update and it will take them there.

GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_UPDATE_CODE).show();

result is the result of the isGooglePlayServicesAvailable method

tyczj
  • 71,600
  • 54
  • 194
  • 296
  • Thanks, this is what I wanted to know, if the check was against the version included in the app or the version in the play store. Is this documented anywhere? – pomber Feb 12 '15 at 15:14
  • yeah you linked to the documentation in your question – tyczj Feb 12 '15 at 15:15
  • But it just says that it is "out of date", this could mean that the version in the device is not the last version. It doesn't need to be a version older than the needed by the app to be "out of date" – pomber Feb 12 '15 at 15:21
  • right, out of date means there is a newer version that the user does not have. if the version in your app is older than the one they have on their device then nothing needs to happen. is that what you mean? – tyczj Feb 12 '15 at 15:23
  • Yes, that. I haven't found any documentation confirming that, and it is not easy to test. – pomber Feb 12 '15 at 15:27
  • well what do you mean there is no documentation its right in the link, i just better explained it i guess – tyczj Feb 12 '15 at 15:29
  • hi tyczj, I used same thing but while calling getErrorDialog returns Null. What can be the issue? – Satish Sojitra Mar 01 '17 at 04:53
6

Here are the docs for GooglePlayServicesUtil: http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html.

Here is where they talking about "ensuring" the user has it installed: https://developer.android.com/google/play-services/setup.html#ensure

This is taken from the Official Iosched 2014 source code here: https://github.com/google/iosched/blob/0a90bf8e6b90e9226f8c15b34eb7b1e4bf6d632e/android/src/main/java/com/google/samples/apps/iosched/util/PlayServicesUtils.java

public class PlayServicesUtils {

    public static boolean checkGooglePlaySevices(final Activity activity) {
        final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
        switch (googlePlayServicesCheck) {
            case ConnectionResult.SUCCESS:
                return true;
            case ConnectionResult.SERVICE_DISABLED:
            case ConnectionResult.SERVICE_INVALID:
            case ConnectionResult.SERVICE_MISSING:
            case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
                Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
                dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialogInterface) {
                        activity.finish();
                    }
                });
                dialog.show();
        }
        return false;
    }
}

Here is how to use it in an Activity: https://github.com/google/iosched/blob/cf1f30b4c752f275518384a9b71404ee501fc473/android/src/main/java/com/google/samples/apps/iosched/ui/BaseActivity.java

@Override
protected void onResume() {
    super.onResume();

    // Verifies the proper version of Google Play Services exists on the device.
    PlayServicesUtils.checkGooglePlaySevices(this);
}
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
5

Does this mean that there is a new version of google play services in the play store?

From the site latest update was on December 2014

Does this mean that the app needs a newer version than the one that is currently installed in the device?

You can check if the device has the higher version ofGoogle Play Service than the one on your app like so:

    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable( getApplicationContext() );
if(status == ConnectionResult.SUCCESS) {
   //OK
}else if(status == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED){
   Toast.makeText(context,"please udpate your google play service",Toast.LENGTH_SHORT).show
}
hrskrs
  • 4,447
  • 5
  • 38
  • 52
1

Documentation was updated, now it is clear:

Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.

pomber
  • 23,132
  • 10
  • 81
  • 94
0

Note that all of the current answers reference GooglePlayServicesUtil which is now deprecated. See GooglePlayServicesUtil vs GoogleApiAvailability for details on how to perform the Google Play Services version compatibility check.

Community
  • 1
  • 1
bmul
  • 390
  • 3
  • 7
0

I resolved this problem by updating the last version of Youtube library available in : https://developers.google.com/youtube/android/player/downloads

In the gradle :

  implementation files('libs/YouTubeAndroidPlayerApi.jar')
odgatelmand
  • 393
  • 1
  • 5
  • 16