question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MapboxGL.setTelemetryEnabled(boolean) crashes on android

See original GitHub issue

Describe the bug
Calling MapboxGL.setTelemetryEnabled(boolean) crashes on android.

To Reproduce
Call MapboxGL.setTelemetryEnabled(boolean) in componentDidMount()

Example:

import React from 'react';
import MapboxGL from '@react-native-mapbox-gl/maps';

class BugReportExample extends React.Component {
  
  componentDidMount() {
    MapboxGL.setTelemetryEnabled(false);
  }

  render() {
    return (
      <MapboxGL.MapView style={{flex: 1}}>
       
      </MapboxGL.MapView>
    );
  }
}

Expected behavior
Telemetry to be set to false and map to function

Actual behavior
iOS works fine. On Android app crashes with following exception:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'void com.mapbox.mapboxsdk.maps.b0.setUserTelemetryRequestState(boolean)' on a null object reference
       at com.mapbox.rctmgl.modules.RCTMGLModule$4.run(RCTMGLModule.java)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5421)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Screenshots
crash

Versions (please complete the following information):

  • Platform: Android
  • Platform OS: Android 10 and 11
  • Device: Samsung S20 and Google pixel emulator
  • Emulator/ Simulator: Same error on both
  • Dev OS: OSX 10.15.4
  • react-native-mapbox-gl Version: 8.1.0
  • React Native Version: 0.63.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
stanjhaecommented, Jul 9, 2022

The issue seems to only occur in Android 12. Mapbox upgraded telemetry dependency to 8.1.0 to be compatible with Android 12 so I did the same.

https://github.com/mapbox/mapbox-gl-native-android/blob/main/CHANGELOG.md#962---july-7-2021

Adding this implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:8.1.0' to android/app/build.gradle fixed my problem.

7reactions
Micgawcommented, Dec 6, 2021

Hi,

I’ve experience same problem as @olofho just in Android 12. For me it work just fine in Android 10 & Android 11.

Versions (please complete the following information):

Platform: Android Platform OS: Android 12 Device: Android emulator & GooglePixel Emulator/ Simulator: Same error on both Dev OS: Windows 10 Pro react-native-mapbox-gl Version: 8.5.0 React Native Version: 0.63.4

Also as @airburst described moving MapboxGL.setTelemetryEnabled(false) to onDidFinishLoadingMap, useEffect or componentDidMount doesn’t help. Telemetry object is always null and it causes application crash.

Can we reopen this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android 12 crash: MapboxGL.setTelemetryEnabled(boolean ...
Calling MapboxGL.setTelemetryEnabled(boolean) crashes on android. In logcat I can see that Telemetry is null and it reproduce even if I wait for map...
Read more >
flutter 3 mapbox not working Targeting S+ (version 31 and ...
I know you might say this question was asked many times but all the answers did not help! I'm using MapBox in my...
Read more >
ConnectivityReceiver (Mapbox Android Core SDK 3.1.0 ...
Get the connectivity state. static boolean, isConnected(Context context). Get the connectivity state as reported by the Android system.
Read more >
Required diagnostic data for Office - Microsoft Learn
It collects the occurrence of Office Add-ins and documents crashes. This is only collected when user has enabled Office Telemetry Dashboard ...
Read more >
@react-native-mapbox-gl/maps | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found