No virtual method setInitialDelay() with WorkManager 2.2.0
See original GitHub issueUsing the latest stable releases of android-job and WorkManager:
implementation 'com.evernote:android-job:1.4.1'
implementation 'androidx.work:work-runtime:2.2.0'
I get this crash when I try to schedule a job:
Caused by: java.lang.NoSuchMethodError: No virtual method setInitialDelay(JLjava/util/concurrent/TimeUnit;)Landroidx/work/OneTimeWorkRequest$Builder; in class Landroidx/work/OneTimeWorkRequest$Builder; or its super classes (declaration of 'androidx.work.OneTimeWorkRequest$Builder' appears in /data/app/com.youneedabudget.evergreen.app.develop-Kx7Jp9uBEt29bXoJWoCEcw==/base.apk)
at com.evernote.android.job.work.JobProxyWorkManager.plantOneOff(JobProxyWorkManager.java:50)
at com.evernote.android.job.JobManager.scheduleWithApi(JobManager.java:244)
at com.evernote.android.job.JobManager.schedule(JobManager.java:199)
at com.evernote.android.job.JobRequest.schedule(JobRequest.java:430)
This is the first time I have tried to add the WorkManager dependency, so I don’t know if it worked with older (or non-AndroidX) WorkManager versions. Previously I was just using android-job’s default implementation without WorkManager, and that has always worked fine.
If I remove the WorkManager dependency then everything works.
I am using Jetifier.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
WorkManager 2.0.1 to 2.1.0 api change "setInitialDelay" when ...
Caused by: java.lang.NoSuchMethodError: No virtual method setInitialDelay(JLjava/util/concurrent/TimeUnit;)Landroidx/work/OneTimeWorkRequest$ ...
Read more >WorkManager - Android Developers
setForegroundAsync() is called, when the app is subject to foreground service restrictions, this will throw the ForegroundServiceStartNotAllowedException. Bug ...
Read more >WorkManager long-running work doesn't work specifying ...
The reason is that the work library still rely on the service manifest which has no foregroundServiceType attribute specified (0x00000000) and i'm requesting...
Read more >OneTimeWorkRequest$Builder.setInitialDelay - Java - Tabnine
setInitialDelay (30, TimeUnit.SECONDS) .build(); WorkManager.getInstance().enqueueUniqueWork("UpdateEpg", ExistingWorkPolicy.REPLACE, updateEpgWorker);.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was curious about the binary incompatibility, so took a closer look at that change between 2.0.1 and 2.2.0 - now I believe I’ve understood the issue and would like to share with the class.
Old:
New:
i.e., that method in question was pulled up into a super type. That’s fine. But the signature changed: the return type was previously
OneTimeWorkRequest.Builder
. In the new version, at compile time, it is still known to be exactly that, when called with aOneTimeWorkRequest
as receiver. But during compilation, due to type erasure, that type parameterB
gets erased to its upper bound:WorkRequest.Builder
. So in 2.2.0, there is really no virtual methodsetInitialDelay(JLjava/util/concurrent/TimeUnit;)Landroidx/work/OneTimeWorkRequest$Builder;
to be found on typeOneTimeWorkRequest$Builder
; it issetInitialDelay(JLjava/util/concurrent/TimeUnit;)Landroidx/work/WorkRequest$Builder;
now.Thanks for making me learn today. https://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html was enlightening.
Thanks for confirming.