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

2

1

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?

Killingsworth answered 7/11, 2023 at 16:35 Comment(0)
A
3

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

Angstrom answered 15/11, 2023 at 4:52 Comment(6)
Good to know it actually works. As for why it doesn't work for me, I'm not entirely sure. Everything you've said I have covered, but LEGACY is always the renderer. It must be as you mentioned about it being included in the emulator. I'll try a different API level/device and see what difference it makes.Killingsworth
Oh right! Totally forgot to mention that you must use an Emulator with Google Play.Angstrom
I edited my answer to include it also.Angstrom
I had actually already tried a Google Play device. I tried it again and it still didn't work. But then I noticed in the notification tray a "set up your device" prompt. I did that, restarted the app, and it worked. If you add that to the "wait for a while after creating a virtual new device" section I'll accept this answer. Thanks.Killingsworth
I think the "set up your device" prompt is the one responsible for enabling the Google Play Services in your device which is required for the New Map renderer. I have edited the answer (I put it under the "need to make sure" section)Angstrom
Potentially. It's just easy to miss and not entirely obvious - especially as I had already updated Play Services on the Play Store.Killingsworth
F
1

The default is now the latest renderer. In fact MapsInitializer.initialize is being deprecated.

The latest renderer requires some Google Play Services library updates with API levels 34 and lower, hence you would need to use a Google Play enabled emulator so that it could pull these updates.

However, API 35 (Android 15) is now also available, and this version already has the required updates, and would work out-of-the-box.

Fir answered 22/7 at 17:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.