In the Google console, I see the following exceptions on multiple devices, for no reason, and I cannot understand the error I am making. Sometimes I get an IllegalArgumentException and sometimes an IllegalStateException
In the emulator, I do not get this exception, so I can not reproduce it!
This is an 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 snippet. I want to mention that I plan to work inside 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 could be the mistake?
source
share