IllegalArgumentException: No such service ComponentInfo{JobIntentService}

3.2k Views Asked by At

SO answers regarding this issue has not helped me, I have declared all permissions and already have, accepted answers in my code.

AppInfoJobService(CustomJobIntentService) throws following error on Android OS 8+ devices and it happens rarely, not able to reproduce. We enqueueWork in BaseActivity's onCreate.We mainly have one activity and fragments.

Fatal Exception: java.lang.IllegalArgumentException: No such service ComponentInfo{<app package>AppInfoJobService}
   at android.os.Parcel.readException(Parcel.java:2009)
   at android.os.Parcel.readException(Parcel.java:1951)
   at android.app.job.IJobScheduler$Stub$Proxy.enqueue(IJobScheduler.java:211)
   at android.app.JobSchedulerImpl.enqueue(JobSchedulerImpl.java:53)
   at android.support.v4.app.JobIntentService$JobWorkEnqueuer.enqueueWork(JobIntentService.java:342)
   at android.support.v4.app.JobIntentService.enqueueWork(JobIntentService.java:522)
   at android.support.v4.app.JobIntentService.enqueueWork(JobIntentService.java:500)
   at <application package>AppInfoJobService.startWork(AppInfoJobService.java:254)
   at <application package>MyApplication.onStartStopChanged(MusicApplication.java:694)
   at <application package>AppStateMonitor.notifyStartStop(AppStateMonitor.java:150)
   at <application package>AppStateMonitor.access$000(AppStateMonitor.java:14)
   at <application package>AppStateMonitor$CreateDestroyRunnable.run(AppStateMonitor.java:71)
   at android.os.Handler.handleCallback(Handler.java:790)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:164)
   at android.app.ActivityThread.main(ActivityThread.java:6545)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857) 
4

There are 4 best solutions below

2
On BEST ANSWER

Problem is finally resolved after switching to the new Android WorkManager

11
On

Note: Starting a separate thread as I do not have enough reputation to comment and want to help the author.

This actually is an issue with LAVA devices having Android Oreo and works absolutely fine with other devices.

I too observed this on LAVA Z60s & LAVA Z61.

Addining related information from crashlytics enter image description here

1
On

My case is I didn't create service in AndroidManifest.xml, so it didn't find that service. To do that, add following to that :

    ...
    /activity>
    <service
        android:name=".YOUR_FOLDER.YOUR_SERVICE_FILENAME"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:exported="false" />
    <receiver
        android:name=".YOUR_FOLDER.YOUR_RECEIVER_FILENAME"></receiver>

</application> 
1
On

You cannot start a service or intentService using method startService while the app is background or application is gets killed and trying to restart the service.

As far as I can understand the situation is (as you said happened rarely) somehow app is trying to restart the application while the app is not in the memory.