Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin crashes on Android on pause #55

Closed
TsvetinaIvanova opened this issue Oct 4, 2016 · 3 comments
Closed

Plugin crashes on Android on pause #55

TsvetinaIvanova opened this issue Oct 4, 2016 · 3 comments

Comments

@TsvetinaIvanova
Copy link

In some scenarios, using the MapBox plugin in an Android app results in a crash when the app is paused. The exception message is:

java.lang.RuntimeException: Unable to pause activity {com.sth.sth/com.sth.sth.TelerikCallbackActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.views.MapView.onPause()' on a null object reference
E/AndroidRuntime(20864): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3366)
E/AndroidRuntime(20864): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3325)
E/AndroidRuntime(20864): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3300)
E/AndroidRuntime(20864): at android.app.ActivityThread.access$1000(ActivityThread.java:156)
E/AndroidRuntime(20864): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1362)
E/AndroidRuntime(20864): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(20864): at android.os.Looper.loop(Looper.java:211)
E/AndroidRuntime(20864): at android.app.ActivityThread.main(ActivityThread.java:5389)
E/AndroidRuntime(20864): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(20864): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(20864): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
E/AndroidRuntime(20864): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
E/AndroidRuntime(20864): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.views.MapView.onPause()' on a null object reference
E/AndroidRuntime(20864): at com.telerik.plugins.mapbox.Mapbox.onPause(Mapbox.java:488)
E/AndroidRuntime(20864): at org.apache.cordova.PluginManager.onPause(PluginManager.java:209)
E/AndroidRuntime(20864): at org.apache.cordova.CordovaWebViewImpl.handlePause(CordovaWebViewImpl.java:430)
E/AndroidRuntime(20864): at org.apache.cordova.CordovaActivity.onPause(CordovaActivity.java:241)
E/AndroidRuntime(20864): at android.app.Activity.performPause(Activity.java:6101)
E/AndroidRuntime(20864): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1310)
E/AndroidRuntime(20864): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3352)
E/AndroidRuntime(20864): ... 11 more

where com.sth.sth is the App Id of the app running on the device.

@AntonDobrev
Copy link

AntonDobrev commented Oct 4, 2016

My first idea is to check whether the mapView exists and then resume it if exists - https://github.com/Telerik-Verified-Plugins/Mapbox/blob/master/src/android/Mapbox.java#L494 . Same for the other lifecycle events.

@EddyVerbruggen
Copy link
Contributor

@TsvetinaIvanova @AntonDobrev I think that check Anton suggests is a wise one - I'll add that!

@EddyVerbruggen
Copy link
Contributor

Should be fine with 1.2.1 (just published).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants