I have an Android app that is using Google's com.google.android.gms.maps.SupportMapFragment. On certain emulators I am running into an issue where instead of displaying the map, the following message is displayed
Your App Name is having trouble with Google Play Services. Please try again.
I checked the logs and I found the following message
GooglePlayServicesUtil: Google Play services out of date. Requires 13400000 but found 12862027
From what I've read this seems to occur when the version of Google Play Services on the emulator is too low of a version to be compatible with the google maps SDK that is being used.
What I would like to do is to check if the installed version of Google Play Services on the device or emulator is sufficient when the app starts so I can have the user remedy the situation instead of seeing the maps error screen. I've tried several different ways of checking for compatibility but in all cases the compatibility check returns a success but the map still shows an error when I navigate to it.
Here's the maps dependency I'm using in build.gradle
implementation "com.google.android.gms:play-services-maps:17.0.0"
And in my top level build.gradle I have the following dependency (although I think this one is just required by Firebase
classpath 'com.google.gms:google-services:4.3.3'
I also have added a google play services version in my Manifest as described below.
So that's the project setup, now here's what I've tried so far to try to determine if Google Play Services is compatible with my maps SDK version at runtime:
Calling
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(applicationContext)
always returns the "success" response, but when I launch the next activity that contains my SupportMapFragment, I see the error message still.
I've also tried calling
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(applicationContext, version)
I'm not entirely sure if I should be passing the client version returned by
GoogleApiAvailability.getInstance().getClientVersion()
Or if I should be passing the APK version returned by
GoogleApiAvailability.getInstance().getApkVersion(applicationContext)
Of if I should be passing the google play services integer that I added to my Manifest
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
which resolves to the value 12451000 in the dependency "play-services-basement" values.xml file
In all cases I still get a success response from the isGooglePlayServicesAvailable() check and still see the error in the SupportMapFragment.
getClientVersion()
returns the value 12451000
getApkVersion()
returns the value 12862027
Since the logs state:
Requires 13400000 but found 12862027
where is the 13400000 coming from? I can't seem to "get" that value back from the GoogleApiAvailability class and AFAIK I'm not setting that value explicitly in any of my code.
What am I doing wrong? How can I verify that a user's Google Play Services version can support the maps SDK version that I'm using at runtime?
Edit: If I change my play-services-maps dependency from 17.0.0 to 16.0.0, the maps displays as expected on the emulator. So it's not an issue where the emulator can't display the map ever, it's just that it can't display 17.0.0 and the check that I'm attempting to do doesn't seem to be working.