question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

after 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:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mauron85commented, Feb 23, 2017

REMARK: the only problem fixing this is what getConfig should return in following situations:

  1. getConfig is called immediately after configure (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 292

Possible solutions:

  1. configure will not run in separate thread (UI will be slightly less responsive while configuring plugin)
  2. add js callbacks to configure so getConfig can be called after configuration is done (not recommended as there are already two callbacks)
  3. getConfig will return empty object or null (bit ugly as you’ve just called configure, so you know it’s configured but plugin will say it’s not).
  4. getConfig will touch db and if there is no record will return instance variable configuration == (some defaults)
0reactions
mauron85commented, Apr 2, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found