I tried to implement the WorkManager API in one of my projects. The app compiles successfully, but when I try to execute some work using WorkManager, it throws the below runtime error:
Runtime Error
Failed resolution of: Landroidx/work/impl/utils/futures/AbstractFuture;
What I know of this error is that it occurs when some class that was available during compile time isn't available during runtime. But this doesn't seem to be the case with me, as when I decompiled my APK, all the necessary classes (including androidx.work.impl.utils.futures.AbstractFuture
) were present there! I tried version 2.3.4, 2.4.0, and 2.5.0_Alpha01 of the work-runtime library, but none of them seemed to work. It'd be really helpful if someone could help me solve this issue. =)
Note: FYI, the project I'm working on is very old, and unfortunately, it still uses Apache Ant. Also, it won't be easy for us to migrate to Gradle anytime soon as it'll affect the whole architecture and take a huge amount of time. So, any solution suggesting changes in build.gradle won't be quite helpful. :)
EDIT: In case anyone needs to see the ADB log:
...
09-05 20:47:01.536 25688 25688 W System.err: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/work/impl/utils/futures/AbstractFuture;
09-05 20:47:01.536 25688 25688 W System.err: at androidx.work.WorkManager.initialize(WorkManager.java:210)
09-05 20:47:01.536 25688 25688 W System.err: at androidx.work.impl.WorkManagerInitializer.onCreate(WorkManagerInitializer.java:40)
09-05 20:47:01.537 25688 25688 W System.err: at android.content.ContentProvider.attachInfo(ContentProvider.java:2102)
09-05 20:47:01.537 25688 25688 W System.err: at android.content.ContentProvider.attachInfo(ContentProvider.java:2076)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.installProvider(ActivityThread.java:7430)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.installContentProviders(ActivityThread.java:6934)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6851)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.access$1600(ActivityThread.java:242)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
09-05 20:47:01.537 25688 25688 W System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
09-05 20:47:01.537 25688 25688 W System.err: at android.os.Looper.loop(Looper.java:227)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.main(ActivityThread.java:7822)
09-05 20:47:01.537 25688 25688 W System.err: at java.lang.reflect.Method.invoke(Native Method)
09-05 20:47:01.537 25688 25688 W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
09-05 20:47:01.537 25688 25688 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026)
09-05 20:47:01.537 25688 25688 W System.err: Caused by: java.lang.ClassNotFoundException: androidx.work.impl.utils.futures.AbstractFuture
09-05 20:47:01.537 25688 25688 W System.err: ... 15 more
...