无法实例化appComponentFactory和multidex类

时间:2020-03-07 07:34:35

标签: java android realm androidx android-multidex

代码可以毫无问题地编译,并且能够构建APK。但是,当我尝试在设备中运行APK时,它崩溃并显示以下日志。

2020-03-07 12:46:42.571 25473-25473/com.package E/LoadedApk: Unable to instantiate appComponentFactory
java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[zip file "/data/app/com.package-Qz3B6TePYQxnRt-qDjb34A==/base.apk"],nativeLibraryDirectories=[/data/app/com.fortunemirror-Qz3B6TePYQxnRt-qDjb34A==/lib/arm64, /data/app/com.package-Qz3B6TePYQxnRt-qDjb34A==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/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.LoadedApk.createAppFactory(LoadedApk.java:256)
    at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:855)
    at android.app.LoadedApk.getClassLoader(LoadedApk.java:950)
    at android.app.LoadedApk.getResources(LoadedApk.java:1188)
    at android.app.ContextImpl.createAppContext(ContextImpl.java:2499)
    at android.app.ContextImpl.createAppContext(ContextImpl.java:2491)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6497)
    at android.app.ActivityThread.access$1600(ActivityThread.java:231)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1952)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7682)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
    Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.package-Qz3B6TePYQxnRt-qDjb34A==/base.apk because: Failure to verify dex file '/data/app/com.package-Qz3B6TePYQxnRt-qDjb34A==/base.apk': Duplicate interface: 'Lio/realm/PalmDataRealmProxyInterface;'
    at dalvik.system.DexFile.openDexFileNative(Native Method)
    at dalvik.system.DexFile.openDexFile(DexFile.java:365)
    at dalvik.system.DexFile.<init>(DexFile.java:107)
    at dalvik.system.DexFile.<init>(DexFile.java:80)
    at dalvik.system.DexPathList.loadDexFile(DexPathList.java:444)
    at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
    at dalvik.system.DexPathList.<init>(DexPathList.java:164)
    at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
    at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
    at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
    at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
    at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
    at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
    at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
    at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:851)

在项目中启用的multidex还会添加multidex依赖项。

科特林版本:1.3.50

我不确定为什么会显示 Duplicate interface: 'Lio/realm/PalmDataRealmProxyInterface;'

编辑:

我还添加了以下内容的multidex忽略文件

-keep class com.package.** { *; } -keep class androidx.** { *; }

还添加了构建类型 multiDexKeepProguard file('multidex.pro')

**更新:**

因此,我尝试从项目中完全删除该领域,然后不再出现这些错误。因此可以确定Realm Gradle插件可以解决此问题。

0 个答案:

没有答案
相关问题