Onesignal-android-sdk: Scheduled service does not require BIND_JOB_SERVICE permission

Created on 28 Oct 2017  路  8Comments  路  Source: OneSignal/OneSignal-Android-SDK

Hello,

I have just upgraded my app with the latest version of the OneSignal SDK (3.6.5).
I was pretty excited for the better support of Android Oreo... but it does not seem to work as expected.

In my app, I have a service extending NotificationExtenderService to implement my custom logic for each notification.
In the AndroidManifest.xml, it is declared as followed:

<service
            android:name=".receivers.NotificationService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.onesignal.NotificationExtender" />
            </intent-filter>
</service>

However my app crashes every time a notification is received:

java.lang.RuntimeException: Unable to start receiver com.onesignal.GcmBroadcastReceiver: java.lang.IllegalArgumentException: Scheduled service ComponentInfo{com.frandroid.app/com.frandroid.app.receivers.NotificationService} does not require android.permission.BIND_JOB_SERVICE permission
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)
    at android.app.ActivityThread.-wrap17(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
 Caused by: java.lang.IllegalArgumentException: Scheduled service ComponentInfo{com.frandroid.app/com.frandroid.app.receivers.NotificationService} does not require android.permission.BIND_JOB_SERVICE permission
    at android.os.Parcel.readException(Parcel.java:1946)
    at android.os.Parcel.readException(Parcel.java:1888)
    at android.app.job.IJobScheduler$Stub$Proxy.enqueue(IJobScheduler.java:211)
    at android.app.JobSchedulerImpl.enqueue(JobSchedulerImpl.java:53)
    at com.onesignal.JobIntentService$JobWorkEnqueuer.enqueueWork(JobIntentService.java:337)
    at com.onesignal.JobIntentService.enqueueWork(JobIntentService.java:515)
    at com.onesignal.NotificationBundleProcessor.startExtenderService(NotificationBundleProcessor.java:434)
    at com.onesignal.NotificationBundleProcessor.processBundleFromReceiver(NotificationBundleProcessor.java:400)
    at com.onesignal.GcmBroadcastReceiver.processOrderBroadcast(GcmBroadcastReceiver.java:110)
    at com.onesignal.GcmBroadcastReceiver.onReceive(GcmBroadcastReceiver.java:67)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
    at android.app.ActivityThread.-wrap17(Unknown Source:0)聽
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)聽
    at android.os.Handler.dispatchMessage(Handler.java:105)聽
    at android.os.Looper.loop(Looper.java:164)聽
    at android.app.ActivityThread.main(ActivityThread.java:6541)聽
    at java.lang.reflect.Method.invoke(Native Method)聽
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)聽
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)聽

So it seems that the new feature introduced in the 3.6.5 version should not require the BIND_JOB_SERVICE permission, which is the case today.

If you need any extra help, feel free to ask!

Documentation

Most helpful comment

Same issue here. Adding android.permission.BIND_JOB_SERVICE works for me

    <service
        android:name=".services.YourCoolNotificationExtenderService"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:exported="false">
        <intent-filter>
            <action android:name="com.onesignal.NotificationExtender" />
        </intent-filter>
    </service>

All 8 comments

I am also getting same problem after updating my app to version 3.6.5 and error occur only in android OS 8.0.0

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.onesignal.GcmBroadcastReceiver: java.lang.IllegalArgumentException: Scheduled service ComponentInfo{com.ved.ca/com.ved.MyNotificationExtenderService} does not require android.permission.BIND_JOB_SERVICE permission
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)
at android.app.ActivityThread.-wrap17(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by java.lang.IllegalArgumentException: Scheduled service ComponentInfo{com.ved.ca/com.ved.MyNotificationExtenderService} does not require android.permission.BIND_JOB_SERVICE permission
at android.os.Parcel.readException(Parcel.java:1946)
at android.os.Parcel.readException(Parcel.java:1888)
at android.app.job.IJobScheduler$Stub$Proxy.enqueue(IJobScheduler.java:211)
at android.app.JobSchedulerImpl.enqueue(JobSchedulerImpl.java:53)
at com.onesignal.JobIntentService$JobWorkEnqueuer.enqueueWork(JobIntentService.java:337)
at com.onesignal.JobIntentService.enqueueWork(JobIntentService.java:515)
at com.onesignal.NotificationBundleProcessor.startExtenderService(NotificationBundleProcessor.java:434)
at com.onesignal.NotificationBundleProcessor.processBundleFromReceiver(NotificationBundleProcessor.java:400)
at com.onesignal.GcmBroadcastReceiver.processOrderBroadcast(GcmBroadcastReceiver.java:110)
at com.onesignal.GcmBroadcastReceiver.onReceive(GcmBroadcastReceiver.java:67)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
at android.app.ActivityThread.-wrap17(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Same issue here. Adding android.permission.BIND_JOB_SERVICE works for me

    <service
        android:name=".services.YourCoolNotificationExtenderService"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:exported="false">
        <intent-filter>
            <action android:name="com.onesignal.NotificationExtender" />
        </intent-filter>
    </service>

@agustinsivoplas Thanks, you are correct. This requirement was added in 3.6.5 as older versions of the OneSignal SDK could not start the app's NotificationExtender when the app was in the background. Issue #346 for reference.

I have updated the OneSignal Background Data and Notification Overriding instructions to include this.

@jkasten2 you may want to update it here too
https://documentation.onesignal.com/docs/android-native-sdk#section--notificationextenderservice-

@thedude61636 Thanks for the catch, it is now updated.

@jkasten2 the documentation which @thedude61636 mentioned still doesn't have the required instruction.

@janbolat Thanks, it might have gotten reverted when we released the latest version of our docs. I made sure it was applied to the latest this time.

Same issue here. Adding android.permission.BIND_JOB_SERVICE works for me

    <service
        android:name=".services.YourCoolNotificationExtenderService"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:exported="false">
        <intent-filter>
            <action android:name="com.onesignal.NotificationExtender" />
        </intent-filter>
    </service>

@agustinsivoplas Thanks ... its works for me

Was this page helpful?
0 / 5 - 0 ratings