maps: [Android] Crash when opening a screen with map in Android 11

Describe the bug
Every time I open a screen that has a map, the application crashes. It seems this has to do with the latest version of Android. Android 11. This crash did not occur before the last update of the operating system.

To Reproduce
Open a screen with a map.

Expected behavior
The screen should show the content (map).

Actual behavior
Crashes the app when we try to open a screen with a map.

Screenshots Screen Shot 2021-03-19 at 2 13 38 PM

Screenshot_20210319-140733_Vibemap

Versions (please complete the following information):

  • Platform: Android
  • Platform OS: Android 11
  • Device: Samsung Galaxy A51
  • Emulator/ Simulator: No
  • Dev OS: [e.g. OSX 11.0.1, Win10]
  • react-native-mapbox-gl Version 8.1.0
  • React Native Version: 0.63.4

Additional context
Logs:

Fatal Exception: java.lang.SecurityException: getDataNetworkTypeForSubscriber: uid 10306 does not have android.permission.READ_PHONE_STATE.
       at android.os.Parcel.createExceptionOrNull(Parcel.java:2385)
       at android.os.Parcel.createException(Parcel.java:2369)
       at android.os.Parcel.readException(Parcel.java:2352)
       at android.os.Parcel.readException(Parcel.java:2294)
       at com.android.internal.telephony.ITelephony$Stub$Proxy.getNetworkTypeForSubscriber(ITelephony.java:8762)
       at android.telephony.TelephonyManager.getNetworkType(TelephonyManager.java:3706)
       at android.telephony.TelephonyManager.getNetworkType(TelephonyManager.java:3670)
       at com.mapbox.android.telemetry.m0.h(:10)
       at com.mapbox.mapboxsdk.module.telemetry.PhoneState.<init>(:21)
       at com.mapbox.mapboxsdk.module.telemetry.TelemetryImpl.onAppUserTurnstileEvent(:25)
       at com.mapbox.mapboxsdk.maps.m.a(:8)
       at com.mapbox.rctmgl.components.mapview.c.<init>(:45)
       at com.mapbox.rctmgl.components.mapview.b.<init>()
       at com.mapbox.rctmgl.components.mapview.RCTMGLAndroidTextureMapViewManager.createViewInstance(:11)
       at com.mapbox.rctmgl.components.mapview.RCTMGLAndroidTextureMapViewManager.createViewInstance()
       at com.facebook.react.uimanager.ViewManager.createViewInstance()
       at com.facebook.react.uimanager.ViewManager.createView()
       at com.facebook.react.uimanager.m.a(:34)
       at com.facebook.react.uimanager.v0$e.execute(:23)
       at com.facebook.react.uimanager.v0$a.run(:114)
       at com.facebook.react.uimanager.v0.j(:53)
       at com.facebook.react.uimanager.v0.j()
       at com.facebook.react.uimanager.v0$j.b(:31)
       at com.facebook.react.uimanager.e.a()
       at com.facebook.react.modules.core.g$d.a(:46)
       at com.facebook.react.modules.core.a$a$a.doFrame(:2)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1008)
       at android.view.Choreographer.doCallbacks(Choreographer.java:809)
       at android.view.Choreographer.doFrame(Choreographer.java:740)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8443)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 21 (9 by maintainers)

Commits related to this issue

Most upvoted comments

This issue has to do with a deprecated Android call. It was fixed in mapbox several months ago but has not been updated in this library. A workaround is to add this line: implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.1.0' to the @react-native-mapbox-gl/maps/android/rctmgl/build.gradle file under the implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0 line.

Hello @ferdicus. I’m using this package as a plugin in an Expo custom development client. It’s a convenient way of adding this great package without having to eject to the bare workflow. This means that Expo handles all Android and iOS code and I can’t access it. But this also means that I can’t implement your suggested solution. Would you reconsider upgrading the android SDK or adding the telemetry library to avoid crashing? I assume more people will start using it as a plugin and encounter this issue.

@waymond91, would be cool if you wouldn’t delete comments of yours - I see the message anyways as a mail notification… If the issue resolved itself, just edit it please, thanks 🙇🏿

aye, agreed - will add the dependency to be included by default