使用AndroidX依赖项开发用于产品组合的健身跟踪应用程序时,遇到以下错误:
“ E / LoadedApk:无法实例化appComponentFactory java.lang.ClassNotFoundException:找不到类“ androidx.appcompat.app.ActionBar;”路径上:DexPathList ...”(下面粘贴了完整错误)。
我的操作栏不会出现,所以我的菜单选项也不会出现。在研究此问题时,我发现这可能是一个依赖项问题,因此我在module:app中的依赖项是...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
// Room components
implementation 'androidx.room:room-runtime:2.0.0'
annotationProcessor 'androidx.room:room-compiler:2.0.0'
androidTestImplementation 'androidx.room:room-testing:2.0.0'
// Lifecycle components
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
}
在项目中...
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
roomVersion = '2.1.0-alpha06'
archLifecycleVersion = '2.1.0-alpha04'
}
先谢谢您!如果有任何其他代码会有所帮助,我将很乐意提供。
java.lang.ClassNotFoundException: Didn't find class "androidx.appcompat.app.ActionBar;" on path: DexPathList[[zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/base.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_dependencies_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_resources_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_0_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_1_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_2_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_3_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_4_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_5_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_6_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_7_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_8_apk.apk", zip file "/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.LoadedApk.createAppFactory(LoadedApk.java:226)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:731)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/zachg.gsctrainingandnutritiontracker-CH8ZaSUoVNBUoZhkK4ObiA==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
... 12 more