ImageCaptureConfig.Builder() 显示错误

ImageCaptureConfig.Builder() is showing error

我正在尝试使用 androidX.camera2 实现相机选项。我正在关注 https://developer.android.com/training/camerax/take-photo

我添加了这个库:

def camerax_version = "1.0.0-alpha08"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-view:1.0.0-alpha05"
implementation "androidx.camera:camera-lifecycle:1.0.0-alpha02"

在 bindPreview 功能上,我添加了图像捕获代码。

        ImageCaptureConfig config = new ImageCaptureConfig.Builder()
                .setTargetRotation(getWindowManager().getDefaultDisplay().getRotation())
                        .build();
        ImageCapture imageCapture = new ImageCapture(config);

但是生成器函数显示错误。

我该如何解决这个错误?

camerax_version 降级为 1.0.0-alpha06 并删除以下依赖项似乎可以解决问题:

implementation "androidx.camera:camera-view:1.0.0-alpha05"
implementation "androidx.camera:camera-extensions:1.0.0-alpha05"
implementation "androidx.camera:camera-lifecycle:1.0.0-alpha02"

这是根据他们的示例应用程序中的 build.gradlecamera-samples/CameraXBasic/app/build.gradle
我猜这会很快修复,因为它仍在 alpha

从 1.0.0-alpha07 配置不同:

ImageCapture imageCapture = new ImageCapture.Builder()
                        .setTargetRotation(getWindowManager().getDefaultDisplay().getRotation())
                        .build();

Camera camera = cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture);

您应该查看 changelog 了解详细信息。