gpt4 book ai didi

java - CameraX 相机核心 :1. 0.0-beta01 在 Camera2Config.java defaultConfig() 处崩溃

转载 作者:行者123 更新时间:2023-12-01 17:46:18 25 4
gpt4 key购买 nike

最近,我尝试了 CameraX camera-core:1.0.0-beta01

Gradle :

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"

defaultConfig {
applicationId "com.example.dryeyescreener"
minSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


def camerax_version = "1.0.0-beta01"
implementation "androidx.camera:camera-core:1.0.0-beta01"
implementation "androidx.camera:camera-camera2:${camerax_version}"
// If you want to use the CameraX View class
implementation "androidx.camera:camera-view:1.0.0-alpha08"
// If you want to use the CameraX Extensions library
implementation "androidx.camera:camera-extensions:1.0.0-alpha08"
// If you want to use the CameraX Lifecycle library
implementation "androidx.camera:camera-lifecycle:${camerax_version}"

从这句话开始:

   cameraProviderFuture = ProcessCameraProvider.getInstance(this);

然后,当我调试到Camera2Config.java时

    public CameraXConfig getCameraXConfig() {
return defaultConfig();
}

它崩溃于: 公共(public)静态 CameraXConfig defaultConfig() {

    // Create the camera factory for creating Camera2 camera objects
CameraFactory.Provider cameraFactoryProvider = Camera2CameraFactory::new;

我搜索了一个使用Kotlin和camera-core beta版本的应用程序示例,没有任何问题。但是代码,我用的是Java版本,肯定崩溃了。

有人成功实现了CameraX Java版本吗?还是我错过了什么?

谢谢,迪

请从 Logcat 中找到以下内容:

java.lang.BootstrapMethodError: Exception from call site #0 bootstrap method
at androidx.camera.camera2.Camera2Config.defaultConfig(Camera2Config.java:52)
at androidx.camera.camera2.Camera2Config$DefaultProvider.getCameraXConfig(Camera2Config.java:88)
at androidx.camera.core.CameraX.getOrCreateInstance(CameraX.java:823)
at androidx.camera.lifecycle.ProcessCameraProvider.getInstance(ProcessCameraProvider.java:103)
at com.example.screener.MainActivity.onCreate(MainActivity.java:144)
at android.app.Activity.performCreate(Activity.java:7326)
at android.app.Activity.performCreate(Activity.java:7317)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3235)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6986)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
Caused by: java.lang.ClassCastException: Bootstrap method returned null
at androidx.camera.camera2.Camera2Config.defaultConfig(Camera2Config.java:52) 
at androidx.camera.camera2.Camera2Config$DefaultProvider.getCameraXConfig(Camera2Config.java:88) 
at androidx.camera.core.CameraX.getOrCreateInstance(CameraX.java:823) 
at androidx.camera.lifecycle.ProcessCameraProvider.getInstance(ProcessCameraProvider.java:103) 
at com.example.screener.MainActivity.onCreate(MainActivity.java:144) 
at android.app.Activity.performCreate(Activity.java:7326) 
at android.app.Activity.performCreate(Activity.java:7317) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3235) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:6986) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

 

最佳答案

似乎是请求 Java 8 导致的崩溃问题。在build.gradle中添加以下内容,问题解决。

android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

关于java - CameraX 相机核心 :1. 0.0-beta01 在 Camera2Config.java defaultConfig() 处崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60862604/

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