Getting crash on JobIntentService onComplete

隐身守侯 提交于 2019-11-30 17:22:03

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/51723024/getting-crash-on-jobintentservice-oncomplete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!