gpt4 book ai didi

android-camerax - java.lang.IllegalArgumentException : Suggested resolution map missing resolution for camera 1

转载 作者:行者123 更新时间:2023-12-04 05:05:48 32 4
gpt4 key购买 nike

使用 CameraX.LensFacing.FRONT 时出现此错误, 在模拟器上测试

E/AndroidRuntime: FATAL EXCEPTION: main
Process: meter.meter, PID: 15289
java.lang.RuntimeException: Unable to start activity ComponentInfo{meter.meter/meter.meter.CameraActivity}: java.lang.IllegalArgumentException: Suggested resolution map missing resolution for camera 1
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
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:1808)
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)
Caused by: java.lang.IllegalArgumentException: Suggested resolution map missing resolution for camera 1
at androidx.camera.core.Preview.onSuggestedResolutionUpdated(Preview.java:310)
at androidx.camera.core.UseCase.updateSuggestedResolution(UseCase.java:375)
at androidx.camera.core.CameraX.calculateSuggestedResolutions(CameraX.java:458)
at androidx.camera.core.CameraX.bindToLifecycle(CameraX.java:144)
at meter.meter.CameraActivity.onCreate(CameraActivity.java:68)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)

代码:
PreviewConfig config = new PreviewConfig.Builder().setLensFacing(CameraX.LensFacing.FRONT).build();

Preview preview = new Preview(config);

TextureView textureView = findViewById(R.id.textureView);


preview.setOnPreviewOutputUpdateListener(new Preview.OnPreviewOutputUpdateListener() {

@Override
public void onUpdated(Preview.PreviewOutput output) {
textureView.setSurfaceTexture(output.getSurfaceTexture());
}
});

ImageCaptureConfig imageCaptureConfig = new ImageCaptureConfig.Builder().build();

imageCapture = new ImageCapture(imageCaptureConfig);
CameraX.bindToLifecycle((LifecycleOwner) this,imageCapture, preview);

最佳答案

添加 setLensFacing(CameraX.LensFacing.FRONT)ImageCaptureConfig应该能解决你的问题

关于android-camerax - java.lang.IllegalArgumentException : Suggested resolution map missing resolution for camera 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56159804/

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