user2711811
user2711811

Reputation:

How to use non-Nexus 5 emulators with Google Play Services dependency for my Google Maps app

My testing approach involves using many emulators of various configurations (makes/models/dimensions/apis/targets).

I have recently upgraded to Android Studio 3.1.

My app is going on 3 years now and uses Google Maps v2 and I'd like to keep maintaining it (Google laughs).

Every emulator (other than the Nexus 5) I have now does not work because it says the Google Play Services needs to be updated and there appears to be no path to resolving it. The Nexus 5 emulators don't have the error but display a blank map background.

When I attempt to remove any dependency on Google Play Services it ends up being a slippery slope (mainly replacing the fused location service).

Question: If I have a Google Play Services dependency (my first mistake perhaps?) in my Google Maps v2 app am I limited to the Nexus 5 emulators (which seem to have its own issues)? If not then how to upgrade the other fine emulators (Pixel, other Nexus, Galaxy...)?

I see other questions out there and I'll continue staring at them but I'd like to understand what is a workable path for future maintenance - removing dependencies, upgrading something...

For reference:

The non-Nexus 5 relevant error is:

(app) won't run unless you update Google Play services

(A big fat 'Update' button is also displayed which throws an exception - presumably because it is not installed on the emulator.)

The Nexus 5 relevant error is:

E/Google Maps Android API: Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above

(Which I can't enable in the AVD manager for Nexus 5 emulators.)

Here's some typical gradle madness - I was trying to bump play-services down to 11.8.0 and this unfortunate magic happens (from gradlew app:depencencies):

+--- com.google.android.gms:play-services-maps:11.8.0 -> 12.0.1 | +--- com.google.android.gms:play-services-base:12.0.1 | | +--- com.google.android.gms:play-services-basement:12.0.1 | | |
+--- com.android.support:support-v4:26.1.0 () | | | --- com.google.android.gms:play-services-basement-license:12.0.1 | |
+--- com.google.android.gms:play-services-tasks:12.0.1 | | | +--- com.google.android.gms:play-services-basement:12.0.1 (
) | | | --- com.google.android.gms:play-services-tasks-license:12.0.1 | | --- com.google.android.gms:play-services-base-license:12.0.1 |
+--- com.google.android.gms:play-services-basement:12.0.1 (*) | --- com.google.android.gms:play-services-maps-license:12.0.1

Celebration

@xiaomi correctly attributed the problem to play-services (or specifically play-services-maps) 12.0.1 so after some gradle battles I bumped all play-* down to 11.8.0 and the non-Nexus emulators work.

Lessons Learned:

Epilogue

Think many times before following this:

enter image description here

Upvotes: 2

Views: 240

Answers (1)

xiaomi
xiaomi

Reputation: 6703

There is often a delay between the latest Google Play Service we can use and the one that the latest emulator can handle.

A solution, when the app on the emulator is asking for an update, is to use a lower version of Google Play Service.

If the map appears as blank, it is usually a problem with the key registration

Upvotes: 1

Related Questions