Danil.B
Danil.B

Reputation: 900

'android.os.Looper.quit()' on a null object reference - Android O

First Activity of my Application starts a STICKY sevice that I'm using for creating notifications. Recently I've noticed a bug on Android O devices: when user starts an Application and then after a few seconds application was in background state the user gets this excpetion:

FATAL EXCEPTION: main
                  Process: com.callcatcher.callcatcher, PID: 27566
                  java.lang.RuntimeException: Unable to stop service callcatcher.call.com.callcatcher.NotificationService@e5b03d1: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Looper.quit()' on a null object reference
                      at android.app.ActivityThread.handleStopService(ActivityThread.java:3563)
                      at android.app.ActivityThread.-wrap26(Unknown Source:0)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721)
                      at android.os.Handler.dispatchMessage(Handler.java:106)
                      at android.os.Looper.loop(Looper.java:171)
                      at android.app.ActivityThread.main(ActivityThread.java:6633)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
                   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.Looper.quit()' on a null object reference
                      at android.app.IntentService.onDestroy(IntentService.java:147)
                      at callcatcher.call.com.callcatcher.NotificationService.onDestroy(NotificationService.java:94)
                      at android.app.ActivityThread.handleStopService(ActivityThread.java:3541)
                      at android.app.ActivityThread.-wrap26(Unknown Source:0) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721) 
                      at android.os.Handler.dispatchMessage(Handler.java:106) 
                      at android.os.Looper.loop(Looper.java:171) 
                      at android.app.ActivityThread.main(ActivityThread.java:6633) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823) 

Upvotes: 1

Views: 395

Answers (1)

Danil.B
Danil.B

Reputation: 900

Still not sure about the reason of exception, but I just switched from IntentService to Service and now it works fine.

Upvotes: 2

Related Questions