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

App crashes when Location is toggled #94

Closed
NesheR16 opened this issue Jul 5, 2016 · 2 comments
Closed

App crashes when Location is toggled #94

NesheR16 opened this issue Jul 5, 2016 · 2 comments

Comments

@NesheR16
Copy link

NesheR16 commented Jul 5, 2016

Hi there,

I finished my app, powered by ionic2, and figured that every time i toggle 'Location service' button

I get the message "unfortunately [myApp] has stopped"

And adb logcat shows something that points to this plugin -

07-05 18:14:37.622 13348 13348 V Diagnostic: onReceiveLocationProviderChange
07-05 18:14:37.632 13348 13348 D AndroidRuntime: Shutting down VM
07-05 18:14:37.632 13348 13348 E AndroidRuntime: FATAL EXCEPTION: main
07-05 18:14:37.632 13348 13348 E AndroidRuntime: Process: myapp.com.myapp, PID: 13348
07-05 18:14:37.632 13348 13348 E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver cordova.plugins.Diagnostic$LocationProviderChangedReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'void cordova.plugins.Diagnostic.notifyLocationStateChange()' on a null object reference
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3642)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at android.app.ActivityThread.access$2000(ActivityThread.java:222)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1877)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at android.os.Looper.loop(Looper.java:158)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7229)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void cordova.plugins.Diagnostic.notifyLocationStateChange()' on a null object reference
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at cordova.plugins.Diagnostic$LocationProviderChangedReceiver.onReceive(Diagnostic.java:837)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3635)
07-05 18:14:37.632 13348 13348 E AndroidRuntime: ... 8 more
07-05 18:14:37.652 3431 3973 V BroadcastQueue: [background] Process cur broadcast BroadcastRecord{da6801c u-1 android.location.MODE_CHANGED qIdx=4}, state= (APP_RECEIVE) DELIVERED for app ProcessRecord{c965a97 25143:com.android.vending/u0a34}

@NesheR16
Copy link
Author

NesheR16 commented Jul 5, 2016

A hotfix that doesn't make my app crash constantly -

into /plugins/cordova.plugins.diagnostic/src/android/Diagnostic.java:

At the end of the file - try & catch this:
instance.notifyLocationStateChange();

@dpa99c
Copy link
Owner

dpa99c commented Jul 5, 2016

This bug was raised as issue #85 (based on this stackoverflow question) and fixed by commit 6f9eac8 which was pushed out to npm as v3.0.4 on 11-June-2016.

I would suggest updating the plugin to the latest version (3.1.0) to resolve this.

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

2 participants