LocationComponent crashing on Android 13 and 12
andrasfecz opened this issue · 1 comments
andrasfecz commented
Tested on android 12 and 13, Pixel 6
In my app using:
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.2'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:6.1.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:6.1.0'
Using these below(downgrading these would break other parts of my app)
compileSdkVersion 33
targetSdkVersion 33
Stacktrace:
Drawable com.my.package_name:drawable/mapbox_user_icon_shadow has unresolved theme attributes! Consider using Resources.getDrawable(int, Theme) or Context.getDrawable(int).
java.lang.RuntimeException
at android.content.res.Resources.getDrawable(Resources.java:908)
at com.mapbox.mapboxsdk.utils.BitmapUtils.getDrawableFromRes(BitmapUtils.java:167)
at com.mapbox.mapboxsdk.utils.BitmapUtils.getDrawableFromRes(BitmapUtils.java:153)
at com.mapbox.mapboxsdk.location.LayerBitmapProvider.generateShadowBitmap(LayerBitmapProvider.java:29)
at com.mapbox.mapboxsdk.location.LocationLayerController.styleBitmaps(LocationLayerController.java:166)
at com.mapbox.mapboxsdk.location.LocationLayerController.applyStyle(LocationLayerController.java:102)
at com.mapbox.mapboxsdk.location.LocationComponent.applyStyle(LocationComponent.java:762)
at com.mapbox.mapboxsdk.location.LocationComponent.activateLocationComponent(LocationComponent.java:521)
In the SDK - BitmapUtils line 167 is:
Drawable drawable = context.getResources().getDrawable(drawableRes);
Crash happens when calling the line locationComponent.activateLocationComponent
in the code below:
// Display user location on the map, enabling the basic pulsing styling
LocationComponentOptions customLocationComponentOptions = LocationComponentOptions.builder(this)
.pulseEnabled(true)
.enableStaleState(false)
.build();
LocationComponent locationComponent = this.mapBoxMap.getLocationComponent();
locationComponent.activateLocationComponent(
LocationComponentActivationOptions.builder(this, this.mapBoxStyle)
.locationComponentOptions(customLocationComponentOptions)
.locationEngineRequest(
new LocationEngineRequest
.Builder(2000L)
.setFastestInterval(2000L)
.build()
)
.useDefaultLocationEngine(true)
.build()
);
// Enable location updates
setLocationUpdates(true);
locationComponent.setLocationComponentEnabled(true);
locationComponent.setCameraMode(CameraMode.TRACKING);
locationComponent.setRenderMode(RenderMode.COMPASS);
Any chance this could be fixed?
Might be a simple change from context.getResources().getDrawable(resID)
to ContextCompat.getDrawable(context, resID)
andrasfecz commented
The issue seems to just be a warning, closin.