java.lang.ClassNotFoundException:找不到类“ com.my_app_name.androidx”

时间:2019-08-09 23:58:42

标签: android react-native-android androidx

尝试将我的Android应用程序从旧版本的React Native(0.55.4)升级到最新版本(0.60.4)之后。现在,我无法启动我的应用程序。每当我尝试启动它时,它就会崩溃。错误消息似乎表明它正在尝试在我的应用程序的命名空间中引用androidx:

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)

我不确定从哪里开始寻找解决此问题的方法。

1 个答案:

答案 0 :(得分:1)

我解决了这个问题。我向AndroidManifest.xml添加了不需要的内容。我从其他地方复制并粘贴了此文件,但事实证明我不需要此文件并引起了问题:

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

删除这些行解决了我的问题。