Skip to content

Lite mode crash "setMapColorScheme not supported in Lite mode" regressed in 8.6.0 (#601) #1028

Description

@Dai1678

Environment details

  1. Maps Compose (GoogleMap with GoogleMapOptions().liteMode(true))
  2. Android 12 / 13 (production devices), Android 15 emulator (Google Play image, API 35)
  3. com.google.maps.android:maps-compose:8.6.0 (the relevant code is unchanged in 9.0.0), com.google.android.gms:play-services-maps:20.0.0

The crash depends on the Google Play services maps module version on the device:

Maps module (policy_maps_core_dynamite) Result
24.16 (Play services 24.23.35, emulator) Crashes
25.06 / 25.34 (production devices) Crashes
26.x (Play services 26.11 emulator, 26.36 Pixel) No crash, color scheme is ignored

So most devices are fine, but devices whose Play services have not been updated for a while crash every time a Lite mode map is shown.

Steps to reproduce

  1. Use maps-compose 8.6.0 and show a GoogleMap in Lite mode without passing mapColorScheme (the default).
  2. Run on a device with an older Play services maps module.
    To reproduce on an emulator: create an AVD from the API 35 Google Play system image, which ships Play services 24.23.35, and do not sign in to a Google account so Play services is not updated.
  3. The app crashes as soon as the map is created (light or dark system theme, both crash).

The bundled LiteModeActivity sample does not pass mapColorScheme either, so it goes through the same code path.

Cause

This looks like a regression of #601, which was fixed by #603 (removing the default MapColorScheme).
#986 made FOLLOW_SYSTEM the default again, for a good reason (maps without an explicit mapColorScheme were stuck in light mode), but the change also reaches Lite mode maps:

Lite mode does not support map color schemes (Lite mode docs).
Recent Play services ignore the call, but older ones throw UnsupportedOperationException, either at MapView.onCreate (from the options) or at the MapUpdater setter.
docs/lite-mode-dark-theme.md (#989) says the SDK ignores MapColorScheme for Lite mode maps, which only holds on recent Play services.

Proposed fix

Keep FOLLOW_SYSTEM as the default from #986, and skip the color scheme only for Lite mode maps:

  1. In the AndroidView factory, apply mapColorScheme to GoogleMapOptions only when opts.liteMode != true.
  2. In MapUpdater, skip map.mapColorScheme = it when the map is in Lite mode (the factory already sets cameraPositionState.isLiteMode).

Non-Lite maps keep following the system theme, and Lite mode maps behave the same on every Play services version as they already do on recent ones.
A try/catch around setMapColorScheme would not be enough, because with maps module 25.34 the crash happens inside MapView.onCreate from the options.
Lite mode maps that should follow the theme can keep using mapStyleOptions, as described in docs/lite-mode-dark-theme.md.

Workaround until fixed: pass mapColorScheme = null explicitly for Lite mode maps.

Code example

GoogleMap(
    modifier = Modifier.size(108.dp, 76.dp),
    cameraPositionState = rememberCameraPositionState {
        position = CameraPosition.fromLatLngZoom(LatLng(35.681236, 139.767125), 13f)
    },
    googleMapOptionsFactory = { GoogleMapOptions().liteMode(true) },
    // mapColorScheme not specified -> defaults to FOLLOW_SYSTEM in 8.6.0 -> crash
    // mapColorScheme = null, // workaround
)

Stack trace

Production device, maps module 25.34 (crashes at MapView.onCreate):

java.lang.UnsupportedOperationException: setMapColorScheme not supported in Lite mode.
    at com.google.maps.api.android.lib6.lite.l.B (:com.google.android.gms.policy_maps_core_dynamite@253425407@253425402025.797495247.797495247:15)
    at com.google.maps.api.android.lib6.impl.cg.N (:com.google.android.gms.policy_maps_core_dynamite@253425407@253425402025.797495247.797495247:10)
    at com.google.maps.api.android.lib6.impl.cg.aW (:com.google.android.gms.policy_maps_core_dynamite@253425407@253425402025.797495247.797495247:290)
    at com.google.maps.api.android.lib6.impl.em.d (:com.google.android.gms.policy_maps_core_dynamite@253425407@253425402025.797495247.797495247:12)
    at com.google.android.gms.maps.internal.r.br (:com.google.android.gms.policy_maps_core_dynamite@253425407@253425402025.797495247.797495247:158)
    at m140.bat.onTransact (:com.google.android.gms.policy_maps_core_dynamite@253425407@253425402025.797495247.797495247:21)
    at android.os.Binder.transact (Binder.java:1164)
    at com.google.android.gms.internal.maps.zza.zzc (zza.java:2)
    at com.google.android.gms.maps.internal.zzl.onCreate (zzl.java:3)
    at com.google.android.gms.maps.zzah.onCreate (zzah.java:3)
    at com.google.android.gms.dynamic.zac.zab (com.google.android.gms:play-services-base@@18.9.0:1)
    at com.google.android.gms.dynamic.zaa.onDelegateCreated (com.google.android.gms:play-services-base@@18.9.0:3)
    at com.google.android.gms.maps.zzai.zzb (zzai.java:5)
    at com.google.android.gms.maps.zzai.createDelegate (zzai.java:1)
    at com.google.android.gms.dynamic.DeferredLifecycleHelper.zaf (DeferredLifecycleHelper.java:6)
    at com.google.android.gms.dynamic.DeferredLifecycleHelper.onCreate (DeferredLifecycleHelper.java:1)
    at com.google.android.gms.maps.MapView.onCreate (com.google.android.gms:play-services-maps@@20.0.0:4)
    at com.google.maps.android.compose.MapLifecycleEventObserver.invokeEvent (MapLifecycleEventObserver.java:434)
    at com.google.maps.android.compose.MapLifecycleEventObserver.moveUp (MapLifecycleEventObserver.java:429)
    ...

Emulator, maps module 24.16 (crashes at the MapUpdater setter):

java.lang.UnsupportedOperationException: setMapColorScheme not supported in Lite mode.
    at com.google.maps.api.android.lib6.lite.l.A(:com.google.android.gms.policy_maps_core_dynamite@241610205@241610202042.636179997.636179997:10)
    at com.google.maps.api.android.lib6.impl.cp.M(:com.google.android.gms.policy_maps_core_dynamite@241610205@241610202042.636179997.636179997:16)
    at com.google.maps.android.compose.MapUpdaterKt$MapUpdater$1$2$15.invoke(MapUpdater.kt:142)
    ...

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p0Highest priority. Critical issue. P0 implies highest priority.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions