androidx.work.impl.WorkManagerInitializer: java.lang.ClassNotFoundException: "androidx.work.impl.WorkManagerInitializer" on path: /data/app/app-2.apk
Asked Answered
P

2

8

I recently migrated my old app's background services to WorkManager. On recent devices (down to sdk 22 included) it looks OK, running repeating work units and scheduling them even across device reboots as expected.

The problem is when I test against old version (old is very relative here), Android sdk 14 which is my minSdkVersion. BTW also WorkManager should have the same: Backwards compatible up to API 14 according to doc. As stated in title, error I get is:

 java.lang.RuntimeException: Unable to get provider androidx.work.impl.WorkManagerInitializer: java.lang.ClassNotFoundException: Didn't find class "androidx.work.impl.WorkManagerInitializer" on path: /data/app/com.example.myapp.apk
    at android.app.ActivityThread.installProvider(ActivityThread.java:4822)

I don't have any custom WorkManager configuration/initialization, I simply added

     implementation 'androidx.work:work-runtime:2.2.0'

to my module's gradle and used it quite typcally to schedule background operations.

Pile answered 28/10, 2019 at 17:43 Comment(0)
P
2

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

Pile answered 28/10, 2019 at 22:0 Comment(1)
I am also facing the same error, but after adding these dependencies implementation 'com.google.android.gms:play-services-fitness:18.0.0', implementation 'com.google.android.gms:play-services-auth:18.0.0'. Turning of the multidex didn't help me. Any other solutions ?Pyle
Z
5

I have the same problem in Androd 19

Reading this and this I solved using

Gradle:

multiDexEnabled true

Java:

public class MyApp extends Application {

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}
Zoology answered 12/6, 2020 at 10:42 Comment(1)
for kotlin implementation override fun attachBaseContext(base: Context?) { super.attachBaseContext(base) MultiDex.install(this); }Drifter
P
2

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

Pile answered 28/10, 2019 at 22:0 Comment(1)
I am also facing the same error, but after adding these dependencies implementation 'com.google.android.gms:play-services-fitness:18.0.0', implementation 'com.google.android.gms:play-services-auth:18.0.0'. Turning of the multidex didn't help me. Any other solutions ?Pyle

© 2022 - 2024 — McMap. All rights reserved.