1

I am trying to implement my app, following the instructions from https://developers.google.com/android/guides/setup, setting the Google Play Services at 9.8.0 in my build.gradle file. As described in How to update Google Play Services to 9.8.7, for testing on an emulator I should downgrade the service. However, it also indicates it should work on a physical device.

  • I am using the new Google Pixel phone which has Google Play Services 9.3.84 installed, Android 7.1.
  • The build.gradle file includes: compile 'com.google.android.gms:play-services:9.8.0'
  • Once running the adb debugger shows

I/FirebaseInitProvider: FirebaseApp initialization unsuccessful

W/GooglePlayServicesUtil: Google Play services out of date. Requires 9877000 but found 9384448

E/MainActivity: Connection to Google API client has failed

I've updated the Google Play Services in the SDK Manager/Tools (version 37), but am running out of ideas. I am unsure how to downgrade the Google Play Services on the Pixel. Am I missing something (possibly obvious?)

EDTI: See the answer, I was missing the correct version of Google Play Services on the phone. The solution implements a check to prevent future mistakes.

Community
  • 1
  • 1
davidverweij
  • 328
  • 1
  • 15

1 Answers1

2

You should add some code to check if there is an update required. Like this below.

GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    googlePlayServicesAvailable = googleApiAvailability.isGooglePlayServicesAvailable((Variables.context));
        if ((googlePlayServicesAvailable == ConnectionResult.SERVICE_MISSING) || (googlePlayServicesAvailable == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED) || (googlePlayServicesAvailable == ConnectionResult.SERVICE_DISABLED)) {
                            activity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
                            googleApiAvailability.getErrorDialog(((Activity) Variables.context), googlePlayServicesAvailable, 0);
        }

You should modify my code to:

  1. Ask the user if they wish to upgrade
  2. Catch if the play store is not installed with a ActivityNotFoundException
apmartin1991
  • 3,064
  • 1
  • 23
  • 44
  • you are totally right. It turns out, as stated in my question, I had a older version of the Google Play Services installed (9.3.84, instead of 9.8.77). The quick fix was to google for the app on chrome (on the phone) and requesting the update. I am currently implementing your solution, as this solves the issue regardless of android phone / Google Play Services version. Thanks! – davidverweij Oct 26 '16 at 14:12