java.lang.ClassNotFoundException: Didn't find class “com.my_app_name.androidx”

感情迁移 提交于 2021-01-20 09:55:30

问题


After attempting to upgrade my Android app from an old version of React Native (0.55.4) to the latest version (0.60.4). Now I am unable to launch my app. It crashes every time I try to launch it. The error message seems to indicate that it's trying to reference androidx within my app's namespace:

08-09 16:52:06.163 25438 25438 E LoadedApk: Unable to instantiate appComponentFactory
08-09 16:52:06.163 25438 25438 E LoadedApk: java.lang.ClassNotFoundException: Didn't find class "com.my_app_name.androidx" on path: DexPathList[[zip file "/data/app/com.my_app_name-oxHQ-U8TpPVneeGtPutIwg==/base.apk"],nativeLibraryDirectories=[/data/app/com.my_app_name-oxHQ-U8TpPVneeGtPutIwg==/lib/arm64, /data/app/com.my_app_name-oxHQ-U8TpPVneeGtPutIwg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
08-09 16:52:06.163 25438 25438 E LoadedApk:   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.LoadedApk.createAppFactory(LoadedApk.java:239)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:768)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.LoadedApk.getClassLoader(LoadedApk.java:847)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.LoadedApk.getResources(LoadedApk.java:1088)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.ContextImpl.createAppContext(ContextImpl.java:2563)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6095)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.ActivityThread.access$1200(ActivityThread.java:237)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1785)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.os.Handler.dispatchMessage(Handler.java:106)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.os.Looper.loop(Looper.java:214)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at android.app.ActivityThread.main(ActivityThread.java:7045)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at java.lang.reflect.Method.invoke(Native Method)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
08-09 16:52:06.163 25438 25438 E LoadedApk:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

I'm not sure where to start looking to fix this issue.


回答1:


I fixed the problem. I added something to my AndroidManifest.xml that I didn't need to. I copied and pasted this from somewhere else, but it turned out that I didn't need this and was causing the problem:

<application
    ...
    tools:replace="android:appComponentFactory"
    android:appComponentFactory="androidx"
>

Removing those lines fixed my problem.



来源:https://stackoverflow.com/questions/57438312/java-lang-classnotfoundexception-didnt-find-class-com-my-app-name-androidx

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