Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting crash on JobIntentService onComplete

I am getting following crash reports for Android 8, but I could not find a reason or fix for this:

java.lang.IllegalArgumentException: Given work is not active: JobWorkItem{id=1 intent=Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.xxx.android cmp=com.xxx.android/com.pushio.manager.PushIOGCMIntentService (has extras) } dcount=1}
at android.app.job.JobParameters.completeWork(JobParameters.java:221)
       at android.support.v4.app.JobIntentService$JobServiceEngineImpl$WrapperWorkItem.complete(JobIntentService.java:267)
       at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:393)
       at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:382)
       at android.os.AsyncTask$2.call(AsyncTask.java:333)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)

I am using PushIO lib for push notifications.

like image 992
Changdeo Jadhav Avatar asked Feb 04 '23 22:02

Changdeo Jadhav


1 Answers

For me this happened when I had 2 different JobIntentService's which both used the same JOB_ID (last parameter of enqueueWork()

So it looks like this ID needs to be unique throughout your whole app.

Edit: Yes, at first I thought it needed to be unique just for the class you are using it for, but that is not true! It needs to be unique for your whole app, per UID. So if a library you use, uses the same ID, you need to change it to something else. Not sure how you should know which ID's are taken already.

Another thing is, that you can not use different ID's for the same class. It also has to be the same ID for the same class, otherwise a second call with a different JOB ID will be ignored

like image 67
Boy Avatar answered Feb 06 '23 15:02

Boy