Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[Android] App crashs when activity extends FragmentActivity #13217

Closed
BharathMG opened this issue Oct 29, 2018 · 2 comments
Closed

[Android] App crashs when activity extends FragmentActivity #13217

BharathMG opened this issue Oct 29, 2018 · 2 comments
Assignees
Labels
Android Mapbox Maps SDK for Android

Comments

@BharathMG
Copy link
Contributor

Steps to reproduce

  1. Extend Activity with FragmentActivity and use MapView in one of the Acitivities in MapboxSDKTestApp.

Expected behavior

Activity should not crash.

Actual behavior

Crashes currently because of srcCompat not giving drawable when accessing through getDrawable in https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java#L114

10-29 14:19:44.546 8982-8982/com.mapbox.mapboxsdk.testapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mapbox.mapboxsdk.testapp, PID: 8982
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.setTintList(android.content.res.ColorStateList)' on a null object reference
        at android.support.v4.graphics.drawable.DrawableCompat.setTintList(DrawableCompat.java:149)
        at com.mapbox.mapboxsdk.utils.ColorUtils.setTintList(ColorUtils.java:114)
        at com.mapbox.mapboxsdk.maps.UiSettings.setAttributionTintColor(UiSettings.java:605)
        at com.mapbox.mapboxsdk.maps.UiSettings.initialiseAttribution(UiSettings.java:227)
        at com.mapbox.mapboxsdk.maps.UiSettings.initialise(UiSettings.java:86)
        at com.mapbox.mapboxsdk.maps.MapboxMap.initialise(MapboxMap.java:96)
        at com.mapbox.mapboxsdk.maps.MapView.initialiseMap(MapView.java:216)
        at com.mapbox.mapboxsdk.maps.MapView.access$900(MapView.java:75)
        at com.mapbox.mapboxsdk.maps.MapView$6.run(MapView.java:345)
        at android.os.Handler.handleCallback(Handler.java:815)
        at android.os.Handler.dispatchMessage(Handler.java:104)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:5737)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)

Replacing FragmentActivity with AppCompatActivity works. But it was not evident when debugging it.

Configuration

Mapbox SDK versions: >= v6.6.1

@philemonmerlet
Copy link
Contributor

Just stumbled on it too. Fixed by replacing ImageViews by v7 AppCompatImageView in mapbox_mapview_internal.xml. I'll add the pull request when I have 2 seconds.

@tobrun
Copy link
Member

tobrun commented Oct 29, 2018

@BharathMG thanks for the insights and @philemonmerlet for providing a patch!
Finalizing this issue in #13222.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

3 participants