maps icon indicating copy to clipboard operation
maps copied to clipboard

Android 12 crash: MapboxGL.setTelemetryEnabled(boolean) causes NullPointerException

Open Micgaw opened this issue 4 years ago • 12 comments

Describe the bug 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 to load.

To Reproduce Call MapboxGL.setTelemetryEnabled(boolean) in componentDidMount(), useEffect(), or `onDidFinishLoadingMap().

Example:

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

const BugReportExample = () => {
  useEffect(() => {
    MapboxGL.setTelemetryEnabled(false);
  }, [])

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

Expected behavior
Map initializes and mapbox telemetry is off.

Actual behavior App crashes on Android 12 (everytime).

Screenshots image-20211213-083423

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

Additional context Problem is similar to issue: #1231 just reproduces only on Android 12

Micgaw avatar Dec 23 '21 11:12 Micgaw

We are also seeing this, but only after changing the compileSdkVersion to 31, from 30.

savv avatar Jan 03 '22 13:01 savv

I think this is related to this: https://github.com/mapbox/mapbox-gl-native-android/blob/main/CHANGELOG.md#962---july-7-2021

Update telemetry to 8.1.0 (okhttp3 variant) and events-core 5.0.0 to make project compatible with Android 12

By default, react-native-mapbox-gl runs on API 9.1.0, so it won't be compatible with API 31, by the looks of it.

savv avatar Jan 03 '22 14:01 savv

We are also seeing this, but only after changing the compileSdkVersion to 31, from 30.

Yes this is causing the issue. And the fix for me was adding the following version of telemetry

implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.1.0'

mjm918 avatar Jan 07 '22 12:01 mjm918

We are also seeing this, but only after changing the compileSdkVersion to 31, from 30.

Yes this is causing the issue. And the fix for me was adding the following version of telemetry

implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.1.0'

I tried this and it did not work for me. Try running ./gradlew uA to uninstall all SDKs and see if it still works.

The only solution that worked for me was to upgrade the mapbox SDK to 9.7.1

savv avatar Jan 07 '22 12:01 savv

@savv Since we have React Native > 0.60, based on docs, no further steps are needed,

I assume we hava to manually put this code in build.gradle?

If yes, do we need all this section or just the line with the SDK?

image

Thank you Chris! Aris

afilp avatar Jan 28 '22 11:01 afilp

Instructions are here https://github.com/react-native-mapbox-gl/maps/blob/master/android/install.md

savv avatar Jan 28 '22 12:01 savv

Yes, I took the above code from there.

I was asking if we need to add the entire block or just the line for 9.7.1, since React Native>0.60 already takes care of the rest (in lower versions though).

Thanks.

afilp avatar Jan 28 '22 14:01 afilp

I think you need all of them, otherwise it won't compile. But I don't know for sure.

savv avatar Jan 28 '22 16:01 savv

Thanks a lot Chris! That's what I thought also and put all of them, I hope they will not cause other problems.

For example, when the package is updated, at some point we have to remove them! How would we know? We won't, something will break eventually in the future due to the usage of "non-defaults" and we will have to remember that we did some manual installation some time ago.

afilp avatar Jan 28 '22 17:01 afilp

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 18 '22 18:04 stale[bot]

As I see it, a fix for new users wanting to run on Android 12 would be to explicitly pin the Mapbox telemetry SDK version in build.gradle as commented here:

We are also seeing this, but only after changing the compileSdkVersion to 31, from 30.

Yes this is causing the issue. And the fix for me was adding the following version of telemetry

implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.1.0'

I'd be happy to provide a simple PR if that is useful, but I don't have a good enough overview to judge whether this is a fix rather than a workaround and whether this could cause problems in other areas I'm not familiar with.

sedot42 avatar Apr 25 '22 09:04 sedot42

It will be closed if no further activity occurs. Thank you for your contributions.

@stalebot I am very sad my activity is not good enough for you. :(

sedot42 avatar May 04 '22 07:05 sedot42