OnLocationStateChange cordova application crashes

喜欢而已 提交于 2019-12-12 03:45:51

问题


The application i am working is basically fetches users location using cordova geolocation plugin, and then show the location on the google maps.

The problem i'm facing is that when i kill the app and turn off/on the location services from settings the application crashes.

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

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void cordova.plugins.Diagnostic.notifyLocationStateChange()' on a null object reference

this is the screen shot of error that i got after running the app directly from Android studio

I'm using diagnostic plugin as well because i'm testing app on API 23 i-e Marshmallow, that needs run time permissions. if i remove diagnostic plugin the app crashes as soon as it starts on Marshmallow.

The app runs on API's below 23 and also it does not crashes when i turn location services On/Off.

Advices/Suggestions are welcomed.


回答1:


This is noted as issue #85 in the plugin repo and is resolved by patch release cordova.plugins.diagnostic@3.0.4:

$ cordova plugin rm cordova.plugins.diagnostic && 
  cordova plugin add cordova.plugins.diagnostic@latest


来源:https://stackoverflow.com/questions/37760900/onlocationstatechange-cordova-application-crashes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!