stephanenicolas / robospice

Repo of the Open Source Android library : RoboSpice. RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.
Apache License 2.0
2.95k stars 545 forks source link

NullPointerException in SpiceService.onDestroy #344

Closed japko closed 10 years ago

japko commented 10 years ago

I recently got this stack in Google Play App console

java.lang.RuntimeException: Unable to stop service com.example.network.CustomSpiceService@4177aa40: java.lang.NullPointerException
at android.app.ActivityThread.handleStopService(ActivityThread.java:2553)
at android.app.ActivityThread.access$2000(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4624)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.octo.android.robospice.SpiceService.onDestroy(SpiceService.java:282)
at android.app.ActivityThread.handleStopService(ActivityThread.java:2536)
... 10 more

It indicates that requestProcessor is null on this line requestProcessor.shouldStop(); in SpiceService class

I had two of these errors one on 2.3.3 (Wildfire S) and one on 4.0.4 (unknown)

Should I null check this line and build my own library or am I doing something wrong?

EDIT:

Also next error on Google Play Console from probably the same Wildfire (but from another day) indicates requestProcessor is null

java.lang.NullPointerException
at com.octo.android.robospice.SpiceService.addSpiceServiceListener(SpiceService.java:423)
at com.octo.android.robospice.SpiceManager$SpiceServiceConnection.onServiceConnected(SpiceManager.java:1085)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1107)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1124)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4277)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
stephanenicolas commented 10 years ago

Which version did you get that in ? Closing as there are not enough details. Re-open if needed.