Android-job: 1.11-SNAPSHOT: com.evernote.android.job.JobManagerCreateException

Created on 22 May 2017  路  21Comments  路  Source: evernote/android-job

Seeing these reported for the first time on the Play store with my app using 1.11-SNAPSHOT.

Android 7.0
com.evernote.android.job.JobManagerCreateException
com.evernote.android.job.JobManager.
java.lang.RuntimeException:
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5884)
at android.app.ActivityThread.-wrap3(ActivityThread.java:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Method.java:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: com.evernote.android.job.JobManagerCreateException:
at com.evernote.android.job.JobManager.(JobManager.java:184)
at com.evernote.android.job.JobManager.create(JobManager.java:107)
at com.dvtonder.chronus.WidgetApplication.onCreate(WidgetApplication.java:166)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1032)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5881)

And on Android 6.0 and 4.2
com.evernote.android.job.JobManagerCreateException
com.evernote.android.job.JobManager.
java.lang.RuntimeException:
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Method.java:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: com.evernote.android.job.JobManagerCreateException:
at com.evernote.android.job.JobManager.(JobManager.java:184)
at com.evernote.android.job.JobManager.create(JobManager.java:107)
at com.dvtonder.chronus.WidgetApplication.onCreate(WidgetApplication.java:166)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6428)

Most helpful comment

JobConfig.setApiEnabled(JobApi.GCM, false);

All 21 comments

Yes, this one is new, see here: https://github.com/evernote/android-job/blob/master/library/src/main/java/com/evernote/android/job/JobManager.java#L184

This exception is thrown when all APIs are disabled, e.g. when the services in the manifest are disabled. This usually happens only with rooted or modded devices. In this case the library can't work and you would schedule jobs and wonder why none of those jobs are running.

At the moment I don't have a better solution than to notify you about this issue as early as possible. Do you have any recommendation or better way to deal with this?

Hmm, no, I cannot think of a better way of handling it. I suppose all I can do it catch that exception in my app and display an error message. Without the Jobs running my app is useless, may a well throw a big red warning triangle :)

Yes, this was my intention how to handle it.

For me it's an Android 7 device, crashlytics reports as not rooted.

What is the reason this crashes?

Xposed? I have no idea, honestly. Any idea what I should do instead?

I got this report in Android 6.0. I suspend android device may not finish boot?

No, it means that no API is supported for some reason. That's the way we setup the JobManager to prevent the crash.

  private void setupJobManager() {
    JobCat.addLogPrinter(new EvernoteJobCreator.JobLibraryLogger());
    JobApi.setForceAllowApi14(true);

    JobManager jobManager = JobManager.create(this);
    jobManager.getConfig().setGcmApiEnabled(false); // is only important for Android 4.X
    jobManager.addJobCreator(new EvernoteJobCreator());
  }

Note that setForceAllowApi14 is deprecated and will be moved to a different place in version 1.2.0.

@vRallev Now that 1.2.0 is out, this answer no longer works, as you anticipated. It seems the location for setting GcmApiEnabled, and setForceAllowApi14 have moved. What is the solution for 1.2.0?

JobConfig. There you can enable/disable APIs.

If I understand correctly, this answer provides work around for the situations where JobManagerCreateException is thrown. Is that correct? If so, even in 1.2.0, do we still need to (1) force allow api 14 (2) disable GcmApi for Android 4.X as shown above?

That's correct. It depends on you. We disable the GCM API, because we only want to use the platform version.

@vRallev For us all reports so far are from non-rooted LG devices running android 7.0. We only support api > 16. So we shouldn't see this error?

On API 24 & 25 android.app.job.JobService is supported. So why does the JobApi.getDefault(context) return a JobApi.V_14 object.

@vRallev
So,聽_JobApi.setForceAllowApi14(true)_聽in v 1.2.+ it should become聽_JobConfig.setForceAllowApi14(true)_
But what to set instead of聽_jobManager.getConfig().setGcmApiEnabled(false)_聽to have the same effect? I found _JobConfig.forceApi()_ but what object needed to send to it.

JobConfig.setApiEnabled(JobApi.GCM, false);

@vRallev For us all reports so far are from non-rooted LG devices running android 7.0. We only support api > 16. So we shouldn't see this error?

Same here, minSdk 16 and on Crashlytics we see a lot of

com.evernote.android.job.JobManagerCreateException: All APIs are disabled, cannot schedule any job

especially on non-rooted devices running android 7.0 (Moto G4).

@vRallev could you please clarify how force allow JobConfig.forceApi(JobApi.V_14) and JobConfig.setApiEnabled(JobApi.GCM, false) could help in this scenario?

would this be the correct workaround?

```
private void setupJobManager() {
try {
JobManager.create(this).addJobCreator(new EvernoteJobCreator());
} catch (JobManagerCreateException e) {
JobConfig.forceApi(JobApi.V_14);
JobConfig.setApiEnabled(JobApi.GCM, false);
JobManager.create(this).addJobCreator(new EvernoteJobCreator());
}
}

This is how we setup the library. We don't use a try-catch block.

    JobConfig.addLogger(new EvernoteJobCreator.JobLibraryLogger());
    JobConfig.setForceAllowApi14(true);
    JobConfig.setApiEnabled(JobApi.GCM, false); // is only important for Android 4.X

    JobManager.create(this).addJobCreator(new EvernoteJobCreator());

We've got the same crash. I'm reading docs and there is written that setApiEnabled is intended only for test purposes. Is it correct?

implementation 'com.evernote:android-job:1.2.6'

Fatal Exception: java.lang.RuntimeException: Unable to create application com.droid4you.application.wallet.Application: com.evernote.android.job.JobManagerCreateException: All APIs are disabled, cannot schedule any job

Galaxy S5 Mini: 6.0.1 (SM-G800H)

Never seen before on older android-job versions. User is using our app for 5 months, so it didn't crashed on 1.2.5 or previous, but start with 1.2.6 (for now just one user with one crash)

@vRallev

        JobConfig.addLogger(new MyJobCreator.JobLibraryLogger());
        JobConfig.setForceAllowApi14(true);
        JobConfig.setApiEnabled(JobApi.GCM, false); // is only important for Android 4.X
        JobManager.create(this).addJobCreator(new MyJobCreator());

I have used the above as mentioned by you. But I am unable to find MyJobCreator.JobLibraryLogger() in the first line. Any pointers here?

Be aware of tool:node="replace" in your AndroidManifest file.
That leads to the same problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

letos picture letos  路  4Comments

vibin picture vibin  路  3Comments

anukools picture anukools  路  7Comments

Haoxiqiang picture Haoxiqiang  路  3Comments

karntrehan picture karntrehan  路  5Comments