Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android java.lang.IllegalArgumentException: No such service ComponentInfo JobScheduler

Tags:

I tried to create a simple JobScheduler job just to see how it works. but I keep getting this exception on runtime, I can't figure it out as I followed the guides step by step.

This is my call:

ComponentName componentName = new ComponentName(getApplicationContext(), TestService.class);  JobInfo jobInfo = new JobInfo.Builder(1,componentName).setPeriodic(300000)                 .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).build();  JobScheduler tm = (JobScheduler)getApplicationContext().getSystemService(Context.JOB_SCHEDULER_SERVICE);  tm.schedule(jobInfo); 

TestService doesn't do anything other than extends JobService.

like image 834
Roee N Avatar asked Oct 27 '15 09:10

Roee N


2 Answers

You need to add the permission android.permission.BIND_JOB_SERVICE into your AndroidManifest.xml

... <service android:name=".TestService"      android:permission="android.permission.BIND_JOB_SERVICE"      android:exported="true"/> ... </application> 

like image 147
Cody Avatar answered Sep 22 '22 17:09

Cody


Try clean project. It was my case.

like image 33
V. Gerasimenko Avatar answered Sep 23 '22 17:09

V. Gerasimenko