app crashes on first start after install (java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.toString()' on a null object reference)
See original GitHub issueafter a fresh install the app crashes immediately as the plugin gets started. It runs fine from second start.
from the adb.logcat
E/AndroidRuntime(10266): FATAL EXCEPTION: pool-2-thread-2
E/AndroidRuntime(10266): Process: com.apptum.app, PID: 10266
E/AndroidRuntime(10266): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.toString()' on a null object reference
E/AndroidRuntime(10266): at org.apache.cordova.PluginResult.<init>(PluginResult.java:55)
E/AndroidRuntime(10266): at org.apache.cordova.CallbackContext.success(CallbackContext.java:72)
E/AndroidRuntime(10266): at com.tenforwardconsulting.cordova.BackgroundGeolocationPlugin$10.run(BackgroundGeolocationPlugin.java:408)
E/AndroidRuntime(10266): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(10266): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(10266): at java.lang.Thread.run(Thread.java:818)
W/ActivityManager( 651): Force finishing activity 1 com.apptum.app/.MainActivity
W/BroadcastQueue( 651): Skipping deliver [background] BroadcastRecord{11cf9798 u-1 android.net.conn.CONNECTIVITY_CHANGE callingPid=-1 callingUid=-1} to ReceiverList{2cf73f14 10266 com.apptum.app/10090/u0 remote:1e5ee567}: process crashing
Plugin version: 2.2.4 Platform: Android OS version: 5.1 Device manufacturer and model: HTC One Plugin configuration options: ´´´ debug: false, desiredAccuracy: 0, stationaryRadius: 6, distanceFilter: 6, stopOnTerminate: true, startOnBoot: false, startForeground: true, interval: 3000, fastestInterval: 3000, activitiesInterval: 5000, stopOnStillActivity: true, stopOnStillMinAccuracy: 30 ´´´
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Attempt to invoke virtual method 'java.lang.String java.lang ...
Restarted android studio and re-installed the app. I somehow works =_=, yes it is magic. Honestly I've no idea which step actually solved...
Read more >Attempt to invoke virtual method 'java.lang.String org.json ...
When calling Adapty.restorePurchases. I use the last version of adapty lib. java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.
Read more >Service | Android Developers
Note that services, like other application objects, run in the main thread ... To invoke the bound service, first make sure that this...
Read more >Fixed Error android error attempt to invoke virtual method
Need Help or Code Support? Feel Free To Contact Us Here http://www.aaviskar.com/support.phpThis video is about Fixed Error android error ...
Read more >Huge crash spike in UserSettingsManager.java
NullPointerException : Attempt to invoke virtual method 'boolean org.json.JSONObject.optBoolean(java.lang.String, boolean)' on a null object reference at ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
REMARK: the only problem fixing this is what
getConfig
should return in following situations:getConfig
is called immediately afterconfigure
(which runs in separate thread) so configuration is not yet stored in db, but plugin instance variable config might be already initialized. Check out line 292Possible solutions:
configure
will not run in separate thread (UI will be slightly less responsive while configuring plugin)configure
so getConfig can be called after configuration is done (not recommended as there are already two callbacks)getConfig
will return empty object or null (bit ugly as you’ve just calledconfigure
, so you know it’s configured but plugin will say it’s not).getConfig
will touch db and if there is no record will return instance variable configuration == (some defaults)Configuration phase was rewritten in latest alpha. It’s not even necessary to call configure anymore - defaults will be used. Should be fixed by now.