I am facing issue with JobIntentService in Android 8.1 OS with Signed apk. Where as its working fine with the debug version. Tried with multiple things but couldnt get solution for this. Here is the crash log i got from Crashalytics.
java.lang.RuntimeException: Unable to stop service com.app.xmpp.XmppService@241c51c6: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.app.JobIntentService$WorkEnqueuer.serviceProcessingFinished()' on a null object reference
at android.app.ActivityThread.handleStopService(ActivityThread.java:3284)
at android.app.ActivityThread.access$2300(ActivityThread.java:188)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1633)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:210)
at android.app.ActivityThread.main(ActivityThread.java:5839)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.app.JobIntentService$WorkEnqueuer.serviceProcessingFinished()' on a null object reference
at android.support.v4.app.JobIntentService.onDestroy(JobIntentService.java:479)
at com.app.xmpp.XmppService.onDestroy(XmppService.java:91)
at android.app.ActivityThread.handleStopService(ActivityThread.java:3265)
at android.app.ActivityThread.access$2300(ActivityThread.java:188)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1633)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:210)
at android.app.ActivityThread.main(ActivityThread.java:5839)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)
Help me if anyone faced similar issues with JobIntentService.
Please note this problem cannot be resolved with handling Nullpointer exception, because the NPE is occurring at JobIntentService which is part of Android Framework and we cannot modify it and this is particularly happening only in Signed APK.
XMPP Service OnDestroy
@Override
public void onDestroy() {
super.onDestroy();
MyXMPP.instance=null;
MyXMPP.instanceCreated=false;
MyXMPP.connection.disconnect();
xmppConnectionCheckHandler.removeCallbacks(xmppConnectionCheckRunnable);
System.out.println("--------------Xmpp Service Stopped-----------");
}
Thanks in advance.