我正在使用this library (JobSchedulerCompat)安排一些工作,但我在随机场合遇到同样的错误。 Logcat看起来像这样:
08-21 15:56:30.232 11953-11953/com.mypackage.jobscheduleexample E/JobServiceCompat﹕ Application unable to handle onStopJob.
java.lang.IllegalArgumentException: Service not registered: me.tatarka.support.internal.job.JobSchedulerService$JobServiceConnection@41905038
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:973)
at android.app.ContextImpl.unbindService(ContextImpl.java:1671)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:536)
at me.tatarka.support.internal.job.JobSchedulerService.finishJob(JobSchedulerService.java:212)
at me.tatarka.support.internal.job.JobSchedulerService.access$000(JobSchedulerService.java:29)
at me.tatarka.support.internal.job.JobSchedulerService$JobServiceConnection$1.acknowledgeStopMessage(JobSchedulerService.java:143)
at me.tatarka.support.job.JobService$JobHandler.ackStopMessage(JobService.java:158)
at me.tatarka.support.job.JobService$JobHandler.handleMessage(JobService.java:111)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5196)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
08-21 15:56:30.232 11953-11953/com.mypackage.jobscheduleexample E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.mypackage.jobscheduleexample, PID: 11953
java.lang.RuntimeException: java.lang.IllegalArgumentException: Service not registered: me.tatarka.support.internal.job.JobSchedulerService$JobServiceConnection@41905038
at me.tatarka.support.job.JobService$JobHandler.handleMessage(JobService.java:114)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5196)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
该服务在Manifest上注册, export 参数为True。
OnStopJob方法我只返回false,没有别的。当我尝试通过执行以下操作取消Job Scheduler中的所有作业时,会发生这种情况:
mJobScheduler.cancelAll();
编辑:抱歉,我不知道如何在Stackoverflow中格式化Logcat,如果您知道,请编辑我的问题。。