gpt4 book ai didi

android - 使用 CameraX 库时崩溃 android : java. lang.ClassNotFoundException

转载 作者:行者123 更新时间:2023-11-29 22:40:11 24 4
gpt4 key购买 nike

我正在使用新的 Jetpack 库 CameraX 制作一个简单的相机应用程序。只要我通过添加依赖项启动应用程序,它就会崩溃。

依赖关系:

implementation "androidx.camera:camera-core:1.0.0-alpha06"
implementation "androidx.camera:camera-camera2:1.0.0-alpha06"

崩溃日志:

2019-11-28 16:16:45.828 26428-26428/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ananth.camerax, PID: 26428
java.lang.RuntimeException: Unable to get provider androidx.camera.camera2.impl.Camera2Initializer: java.lang.ClassNotFoundException: Didn't find class "androidx.camera.camera2.impl.Camera2Initializer" on path: DexPathList[[zip file "/data/app/com.ananth.camerax-5fK5oVGKPPgZn_ITpYwEsA==/base.apk"],nativeLibraryDirectories=[/data/app/com.ananth.camerax-5fK5oVGKPPgZn_ITpYwEsA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6444)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5946)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5858)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1690)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:6698)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.camera.camera2.impl.Camera2Initializer" on path: DexPathList[[zip file "/data/app/com.ananth.camerax-5fK5oVGKPPgZn_ITpYwEsA==/base.apk"],nativeLibraryDirectories=[/data/app/com.ananth.camerax-5fK5oVGKPPgZn_ITpYwEsA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.ActivityThread.installProvider(ActivityThread.java:6420)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5946) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5858) 
at android.app.ActivityThread.-wrap1(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1690) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:173) 
at android.app.ActivityThread.main(ActivityThread.java:6698) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) 
Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.ananth.camerax-5fK5oVGKPPgZn_ITpYwEsA==/base.apk because: Failure to verify dex file '/data/app/com.ananth.camerax-5fK5oVGKPPgZn_ITpYwEsA==/base.apk': Bad method handle type 7
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:353)
at dalvik.system.DexFile.<init>(DexFile.java:100)
at dalvik.system.DexFile.<init>(DexFile.java:74)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
at dalvik.system.DexPathList.<init>(DexPathList.java:157)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:681)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:714)
at android.app.LoadedApk.getResources(LoadedApk.java:941)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2254)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5755)
... 8 more

我在 SO 上找不到任何答案。

最佳答案

错误:

// CameraX
def camerax_version = "1.0.0-beta07"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:1.0.0-alpha20"

解决方案:

// CameraX
def camerax_version = '1.0.0-rc01'
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:1.0.0-alpha20"

关于android - 使用 CameraX 库时崩溃 android : java. lang.ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59087196/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com