mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

[Android] NullPointerException in ConnectivityReceiver => onConnectivityChanged

Open K-Leon opened this issue 10 years ago • 14 comments

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)

K-Leon avatar Oct 27 '16 08:10 K-Leon

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.

tobrun avatar Oct 31 '16 08:10 tobrun

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

fab1an avatar Dec 29 '16 09:12 fab1an

This was released in 4.2.0 and 4.2.1

tobrun avatar Dec 29 '16 15:12 tobrun

Thank you, tobrun.

fab1an avatar Dec 30 '16 09:12 fab1an

@tobrun Are you sure this fix was included in 4.2.1? https://github.com/mapbox/mapbox-gl-native/blob/release-android-v4.2.1/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java#L2607

keenubee avatar Jan 09 '17 15:01 keenubee

@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 avatar Jan 11 '17 09:01 fab1an

@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)

keenubee avatar Jan 11 '17 11:01 keenubee

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

insidelabs avatar Jan 14 '17 21:01 insidelabs

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.

K-Leon avatar Jan 14 '17 21:01 K-Leon

We also face this issue.

skeie avatar Jan 16 '17 06:01 skeie

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 avatar Jan 16 '17 06:01 tobrun

@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 avatar Jan 16 '17 07:01 fab1an

@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

tobrun avatar Jan 16 '17 09:01 tobrun

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

tobrun avatar Jan 24 '17 08:01 tobrun