Android 7+ IllegalStateException or IllegalArgumentException without message at JobScheduler.schedule

Viewed 391

In the Google console I am seeing the following exceptions on several devices, whitout reason and I can't figure out the error I am making. Sometimes I am getting IllegalArgumentException and sometimes IllegalStateException

In the emulator I do not get this exceptions, so I can't reproduce it!

This is the exception:

java.lang.RuntimeException: 
  at android.os.AsyncTask$3.done(AsyncTask.java:318)
  at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
  at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
  at java.util.concurrent.FutureTask.run(FutureTask.java:242)
  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
  at java.lang.Thread.run(Thread.java:762)
Caused by: java.lang.IllegalStateException: 
  at android.os.Parcel.readException(Parcel.java:1701)
  at android.os.Parcel.readException(Parcel.java:1646)
  at android.app.job.IJobScheduler$Stub$Proxy.schedule(IJobScheduler.java:158)
  at android.app.JobSchedulerImpl.schedule(JobSchedulerImpl.java:42)
  at do.that.Worker$1.doInBackground(Worker.java:907)
  at android.os.AsyncTask$2.call(AsyncTask.java:304)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)

And here is the code fragment. I want to mention, that I schedule the Job inside an AsyncTask.

    ComponentName serviceComponent = new ComponentName(context, RetryJobSchedulerService.class);
    JobInfo.Builder builder = new JobInfo.Builder(kJobId++, serviceComponent);
    builder.setMinimumLatency(5 * 1000);
    builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
    JobScheduler jobScheduler =  (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
    int result = jobScheduler.schedule(builder.build());

I set the permission for the service:

android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true"

What can the error be?

0 Answers
Related