Search code examples
androidgoogle-maps

Does cloud-based map styling for Android MapView work on virtual devices?


I've followed the instructions to the letter to get cloud-based map styling working with my Android app but the normal style loads every time.

I've linked the map ID to the map style, and I've provided the map ID in the layout resource file.

According to this article, cloud-based map styling requires the new map renderer to work. In the activity, I requested the latest renderer via MapsInitializer.initialize but when I check the renderer in the callback it is always LEGACY.

Google Play Services are fully up to date on the emulated device - a Pixel 7 with Android 13.0 - and there's plenty of storage. Maps SDK for Android is com.google.android.gms:play-services-maps:18.2.0.

Does cloud-based map styling work with any virtual device?


Solution

  • Short answer is Yes

    Longer answer is what you have mentioned. You need the New Map Renderer to make Cloud Based Maps Styling work.

    As of com.google.android.gms:play-services-maps:18.2.0 the default renderer is already the New One so no need to opt in.

    Before 18.2, you still need to opt in for the New Map Renderer. But as of writing this answer, the link to the New Map Renderer documentation now specifies to opt out of the New Map renderer to continue using the Old Map Renderer.

    So make sure that you're not using MapsInitializer.initialize to actually opt out of the New Map Renderer.

    Before 18.2, there were times where you need to wait for the LATEST renderer to be included in your emulator so you might need to wait for a while after creating a virtual new device.

    With that said, here's what you need to make sure:

    Here's an example to prove that Cloud Based Maps Styling works fine in a Virtual Device using Pixel 3 API 33 in Android Studio:

    Emulator sample

    repo used and modified: https://github.com/googlemaps/android-samples