Jayce
Jayce

Reputation: 842

Android Didn't find class "androidx.work.impl.WorkManagerInitializer

I am truly at a loss, my app randomly now has this crash report on crashlytics and I can't seem to duplicate it or even figure out where it would be crashing because it doesn't tell me. It just started giving me these crashes last week. My min sdk is 24, I have tried to target 29 & 30 and the crashes still appear. Can anyone hint how I can actually track this down since it doesn't appear on my device directly or where I could maybe start to look? No where in my project do I use WorkManagerInitializer unless it is part of a library that I don't know about.

Fatal Exception: java.lang.RuntimeException: Unable to get provider androidx.work.impl.WorkManagerInitializer: java.lang.ClassNotFoundException: Didn't find class "androidx.work.impl.WorkManagerInitializer" on path: DexPathList[[zip file "/data/app/com.myapp-TEzM5SrnhKhfsdQ-sNWHsQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-TEzM5SrnhKhfsdQ-sNWHsQ==/lib/arm64, /system/lib64]]
   at android.app.ActivityThread.installProvider(ActivityThread.java:7462)
   at android.app.ActivityThread.installContentProviders(ActivityThread.java:7002)
   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6890)
   at android.app.ActivityThread.access$1300(ActivityThread.java:269)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2010)
   at android.os.Handler.dispatchMessage(Handler.java:107)
   at android.os.Looper.loop(Looper.java:237)
   at android.app.ActivityThread.main(ActivityThread.java:7860)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

Caused by java.lang.ClassNotFoundException: Didn't find class "androidx.work.impl.WorkManagerInitializer" on path: DexPathList[[zip file "/data/app/com.myapp-TEzM5SrnhKhfsdQ-sNWHsQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-TEzM5SrnhKhfsdQ-sNWHsQ==/lib/arm64, /system/lib64]]
   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
   at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:147)
   at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:67)
   at android.app.ActivityThread.installProvider(ActivityThread.java:7446)
   at android.app.ActivityThread.installContentProviders(ActivityThread.java:7002)
   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6890)
   at android.app.ActivityThread.access$1300(ActivityThread.java:269)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2010)
   at android.os.Handler.dispatchMessage(Handler.java:107)
   at android.os.Looper.loop(Looper.java:237)
   at android.app.ActivityThread.main(ActivityThread.java:7860)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)

Upvotes: 3

Views: 2083

Answers (2)

Justin
Justin

Reputation: 18176

The solution is to add this line to your proguard file:

-keep class androidx.work.** { *; }

Upvotes: 3

Shoaib Kakal
Shoaib Kakal

Reputation: 1336

The problem was caused by multiDexEnabled true which I had in defaultConfig for unknown reasons. I found it out after some digging and this issue

If the above doesn't help then try this

Gradle

multiDexEnabled true

Java

public class MyApp extends Application {

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

Upvotes: 0

Related Questions