Question

Currently, I'm migrating previous Google services which makes use of jar library to Google Play Services.

  • Google AdMob
  • Google Analytics
  • Google Drive

However, in migration guide, Google doesn't mention what we should do, for devices without Google Play Services, or without up-to-dated Google Play Services.

So, should we just ignore users without Google Play Services, or there is a fall back plan?

Having to maintain separate set of jar files and legacy code for fall back plan is quite cumbersome. Also, there might be conflicting issues, having jar files and GPS side by side. Utilize both Play Services and AdMob SDK

Was it helpful?

Solution

1. Checking for Google Play Services

As documented here you should always ensure that:

  1. The Google Play Services APK is present at all.
  2. That the correct version is installed.

Mostly you would perform those checks in the onResume() method. The GooglePlayServiceUtils has a method called isGooglePlayServicesAvailable(...) that checks both if the Google Play Services are installed and that they are the correct version. It returns an int error code that tells you roughly what's wrong:

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

    int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
    switch(errorCode) {
        case ConnectionResult.SUCCESS:
            // Google Play Services installed and up to date
            break;

        case ConnectionResult.SERVICE_MISSING:
            // Google Play services is missing on this device.
            break;

        case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
            // The installed version of Google Play services is out of date.
            break;

        case ConnectionResult.SERVICE_DISABLED:
            // The installed version of Google Play services has been disabled on this device.
            break;

        case ConnectionResult.SERVICE_INVALID:
            // The version of the Google Play services installed on this device is not authentic.
            break;

        case ConnectionResult.DATE_INVALID:
            // The device date is likely set incorrectly.
            break;          
    }
}

You can use a method like showErrorDialogFragment(...) of the GooglePlayServiceUtils to show an appropriate error message:

int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
if(GooglePlayServiceUtil.showErrorDialogFragment(errorCode, getActivity(), REQUEST_CODE)) {
    // Dialog was shown
} else {
    // Dialog was not shown.
}

The dialog is only shown when the error code is something other than ConnectionResult.SUCCESS.

You can find documentation for the GooglePlayServiceUtil class here.

2. Fallback

Whether you need a fallback depends solely on your app and the market you are targeting. For example if you publish it to the Google Play Store - which I assume you do since you use Google Play Services - then you don't really need a fallback. Because for people to download your app they first need the Google Play Store, and if they have the Google Play Store than they have access to the Google Play Services. It's of course a whole different story if you want to publish it for Amazon devices, or in the Nokia Store, because devices that have those don't have the Google Play Store or Google Play Services. Also in markets like China there are hardly any Android devices with the Google Play Store or any Google Services, so essentially you have to decide if it is necessary for your app, but as I said if you publish it to the Google Play Store I wouldn't worry about it. The checks and also the error dialog I mentioned above should be more than enough to ensure that your app works well. The rollout of new versions of the Google Play Services APK is normally pretty quick. It might take a few days, but after that most devices have received the update. You also have to think about one thing: If you develop your app to require features of the current Google Play Services than you most likely won't run into any problems since almost all devices already have the current version, it would be rather difficult to find a device that is not up to date. You just have to be careful when you are quickly pushing out an update to your app that uses some new feature that has been introduced just a few days ago. In that case you might run into more problems.

But in the end you have to remember that this all depends on the country you release your app in and on the ecosystems you want to release your app for.

I hope I could answer your question and if you have any further questions feel free to ask!

OTHER TIPS

I use Analytics and Admob for my app, and they both work with devices that don't have Google play services installed

Analytics: link here

Note: The SDK can be used and will work on devices that do not have Google Play Services. In this case the SDK will will automatically fall back to local dispatching.

Admob: see this question on SO. I have also read in a Google Group discussion about this topic and one developer in the Admob team has confirmed that it will work but now I can't find the link.

For other Google Play Services libraries, I don't use them so I cannot confirm about them

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top