Getting crash on JobIntentService onComplete

前端 未结 1 1959
孤独总比滥情好
孤独总比滥情好 2021-01-18 04:54

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 acti         


        
相关标签:
1条回答
  • 2021-01-18 05:22

    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

    0 讨论(0)
提交回复
热议问题