Mapbox-gl-native: [Android] NullPointerException in ConnectivityReceiver => onConnectivityChanged

Created on 27 Oct 2016  路  14Comments  路  Source: mapbox/mapbox-gl-native

Platform: Android
Mapbox SDK version: com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.1

Just got a crashreport in Crashlytics raising a Null Pointer Exception:

Image ( Looks better ):

image

It's on a Customer Device in Production - so i don't know how to reproduce, but maybe this helps.

Full Stacktrace:

Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010 (has extras) } in com.mapbox.mapboxsdk.maps.MapView$ConnectivityReceiver@23951ec3 at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:876) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697) Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.NativeMapView.setReachability(boolean)' on a null object reference at com.mapbox.mapboxsdk.maps.MapView.onConnectivityChanged(MapView.java:2357) at com.mapbox.mapboxsdk.maps.MapView.access$3100(MapView.java:115) at com.mapbox.mapboxsdk.maps.MapView$ConnectivityReceiver.onReceive(MapView.java:2342) at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:866) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)

Android crash

Most helpful comment

Thank you all for reaching out and requesting this fix, we are currently thinking about a 4.2.2 bugfix release that would include a fix for this issue. Will update the ticket if there is a concrete eta.

All 14 comments

Thank your for reporting, I think the use-case will be destroying the underlying map object and at the same time still receiving connectivity change events. Added a check to validate if the map isn't destroyed should resolve this.

Is this bugfix already in a release? I searched the notes, but couldn't find anything.

This was released in 4.2.0 and 4.2.1

Thank you, tobrun.

@keenubee I don't think it was.

@tobrun Is there any way to work around this, this is the only thing crashing our production app :(.

@fab1an I was tried to build a custom package with Jitpack but it's not compiles libmapbox-gl.so library (it is originally compiling with Bitrise as i know)

+1 - We're seeing a significant amount of crashes relating to this.

Is there an easy way to backport this to 4.1.1?
React Native Mapbox Gl won't work with 4.2 and nobody knows the reason so far.. sigfault.

We also face this issue.

Thank you all for reaching out and requesting this fix, we are currently thinking about a 4.2.2 bugfix release that would include a fix for this issue. Will update the ticket if there is a concrete eta.

@tobrun That sounds good. If the version still takes some time, however, do you think you could help us make a custom build ourselves?

@fab1an that is possible, though not advisable, to do this you need clone this repo, make sure your system can build this project, check out the release-android-v4.2.1 , cherry pick 8dbff2ac47492eeced9f04118d2a48524846fce7 and build the related aar files with make apackage

Update as we are planning a v4.2.2 release including this fix, release branch will release-android-v4.2.2

Was this page helpful?
0 / 5 - 0 ratings