43

I am getting does not require android.permission.BIND_JOB_SERVICE permission error while scheduling my JobService and I already have the bind permissions. Below is my code.

JobScheduler jobScheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
ComponentName componentName = new ComponentName(MainActivity.this,MyJobService.class);
JobInfo.Builder jobInfo = new JobInfo.Builder(101, componentName).setPeriodic(2000);
jobScheduler.schedule(jobInfo.build())

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

Error:

java.lang.IllegalArgumentException: Scheduled service ComponentInfo{services.acadglid.com.acadgildservices/services.com.es.MyJobService} does not require android.permission.BIND_JOB_SERVICE permission

Magnus
  • 17,157
  • 19
  • 104
  • 189
Akhilesh Mani
  • 3,502
  • 5
  • 28
  • 59

2 Answers2

72

To solve this problem:

Scheduled service ComponentInfo{.........} does not require android.permission.BIND_JOB_SERVICE permission

add the permission:

        android:permission="android.permission.BIND_JOB_SERVICE"

but requires the property:

android:exported="..."

android:exported: Whether or not the broadcast receiver can receive messages from sources outside its application — "true" if it can, and "false" if not.

For example:

    <service android:name="com.jorgesys.jobscheduler.MyService"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:exported="true"/>
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • 6
    This worked for me beautifully! I added the following service into my AndroidManifest.xml file: ```` – Martin Erlic Nov 22 '18 at 23:57
  • @Elenasys In the past, my Alarm Notifications fired correctly and with no app crashes. Then app starting crashing with the same Logcat error message in the question above. I added the permission you recommended and no more crashes. What changed with the OS? Is the permission now a requirement for firing Alarm Notifications? – AJW May 30 '19 at 04:30
  • This is not working in my case,... I am using job intent service – Abdul Waheed Nov 26 '19 at 16:34
12

There's a typo in your Android Manifest.

Just change the following line:

android:permission="android:permission.BIND_JOB_SERVICE"
                           ^
                           |
                    This " : " is WRONG!

to

android:permission="android.permission.BIND_JOB_SERVICE"

So just change : (colon) in to . (dot).

Boken
  • 4,825
  • 10
  • 32
  • 42