Describe the bug
As of this commit, both CameraPosition and VisibleRegion uses a variant of readParcelable which was introduced in Android 13 (API Level 33). However, this method has a known compatibility issue with R8 fullMode, as described here.
As a result, the app crashes with the following exception whenever this code path gets invoked:
Exception java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Class.isInterface()' on a null object reference
at java.lang.Class.isAssignableFrom (Class.java:589)
at android.os.Parcel.readParcelableCreatorInternal (Parcel.java:4865)
at android.os.Parcel.readParcelableInternal (Parcel.java:4778)
at android.os.Parcel.readParcelable (Parcel.java:4769)
at com.mapbox.mapboxsdk.camera.CameraPosition$Companion$CREATOR$1.createFromParcel (CameraPosition.java:523)
at com.mapbox.mapboxsdk.camera.CameraPosition$Companion$CREATOR$1.createFromParcel (CameraPosition.java:523)
at android.os.Parcel.readParcelableInternal (Parcel.java:4787)
at android.os.Parcel.readParcelable (Parcel.java:4755)
at com.mapbox.mapboxsdk.maps.MapboxMapOptions.<init> (MapboxMapOptions.java:2)
at com.mapbox.mapboxsdk.maps.MapboxMapOptions.<init> (MapboxMapOptions.java:2)
at com.mapbox.mapboxsdk.maps.MapboxMapOptions$1.createFromParcel (MapboxMapOptions.java:404)
at com.mapbox.mapboxsdk.maps.MapboxMapOptions$1.createFromParcel (MapboxMapOptions.java:404)
at android.os.Parcel.readParcelableInternal (Parcel.java:4787)
at android.os.Parcel.readValue (Parcel.java:4544)
at android.os.Parcel.readValue (Parcel.java:4324)
at android.os.Parcel.-$$Nest$mreadValue
at android.os.Parcel$LazyValue.apply (Parcel.java:4422)
at android.os.Parcel$LazyValue.apply (Parcel.java:4381)
at android.os.BaseBundle.getValueAt (BaseBundle.java:394)
at android.os.BaseBundle.getValue (BaseBundle.java:374)
at android.os.BaseBundle.getValue (BaseBundle.java:357)
at android.os.BaseBundle.getValue (BaseBundle.java:350)
at android.os.Bundle.getParcelable (Bundle.java:913)
at com.mapbox.mapboxsdk.utils.MapFragmentUtils.resolveArgs (MapFragmentUtils.java:94)
(user code)
To Reproduce
One way to reproduce this issue is to use MapFragmentUtils.createFragmentArgs either directly or indirectly, e.g. by calling MapFragment.newInstance and passing a MapLibreMapOptions instance.
The following conditions should also be met for the crash to happen:
Android Gradle Plugin 8.0+ should be used.
R8 needs to be enabled (minifyEnabled true)
R8 full mode also needs enabled, either by setting android.enableR8.fullMode=true to true in gradle.properties or by completely omitting it.
Platform information (please complete the following information):
This issue only affects devices running Android 13 (API Level 33).
Additional context
The following versions are affected:
android-v10.2.0
android-v10.1.0
android-v10.0.2
android-v10.0.1
android-v10.0.0
android-v10.0.0-pre.0
One possible workaround would be to use BundleCompat.getParcelable(Bundle, String, Class) from androidx.core:core-ktx:1.10.0, which falls back to the old behaviour on API levels <34.
Describe the bug As of this commit, both
CameraPosition
andVisibleRegion
uses a variant of readParcelable which was introduced in Android 13 (API Level 33). However, this method has a known compatibility issue with R8 fullMode, as described here.As a result, the app crashes with the following exception whenever this code path gets invoked:
To Reproduce One way to reproduce this issue is to use
MapFragmentUtils.createFragmentArgs
either directly or indirectly, e.g. by callingMapFragment.newInstance
and passing aMapLibreMapOptions
instance.The following conditions should also be met for the crash to happen:
android.enableR8.fullMode=true
to true ingradle.properties
or by completely omitting it.Platform information (please complete the following information): This issue only affects devices running Android 13 (API Level 33).
Additional context The following versions are affected:
One possible workaround would be to use
BundleCompat.getParcelable(Bundle, String, Class)
fromandroidx.core:core-ktx:1.10.0
, which falls back to the old behaviour on API levels <34.