androidx.work.impl.WorkManagerInitializer: java.lang.ClassNotFoundException: “androidx.work.impl.WorkManagerInitializer” on path: /data/app/app-2.apk

99封情书 提交于 2021-01-02 08:05:47

问题


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.


回答1:


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




回答2:


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);
}


来源:https://stackoverflow.com/questions/58595909/androidx-work-impl-workmanagerinitializer-java-lang-classnotfoundexception-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!