Java、Android、camerax编程。错误:找不到符号。符号:类生成器

Java、Android、camerax编程。错误:找不到符号。符号:类生成器,java,android,android-camerax,Java,Android,Android Camerax,我正在尝试使用Android智能手机,通过使用Android的图书馆拍照。 我正在关注他们的观点。 首先,我需要初始化ImageCapturer: ImageCapture imageCapture = new ImageCapture.Builder() .setTargetRotation(view.getDisplay().getRotation()) .build(); cameraProvider.bindToLifecycle(lifecycleOwner, cam

我正在尝试使用Android智能手机,通过使用Android的图书馆拍照。
我正在关注他们的观点。 首先,我需要初始化ImageCapturer:

ImageCapture imageCapture =
new ImageCapture.Builder()
    .setTargetRotation(view.getDisplay().getRotation())
    .build();

cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, imageCapture, imageAnalysis, preview);
问题是我收到错误消息,无法执行代码:

    ImageCapture imageCapture = new ImageCapture.Builder().setTargetRotation(view.getDisplay().getRotation()).build();
                                                ^
  symbol:   class Builder
我在gradle文件中包含了camerax的依赖项:

apply plugin: 'com.android.application'

repositories {
    jcenter()
}

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

    compileSdkVersion 28
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "org.pytorch.digitrecognizer"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            debuggable true
        }
    }
}

dependencies {
    def camerax_version = '1.0.0-alpha06'
    implementation "androidx.camera:camera-core:${camerax_version}"
    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'org.pytorch:pytorch_android:1.4.0'
    implementation 'org.pytorch:pytorch_android_torchvision:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

我不知道为什么它不能识别
.builderI
。我希望有人能帮助我^ ^

如果您使用的是alpha06版本的camerax core工件,那么在camerax core的版本07中引入了使用用例生成器构建用例。对于alpha06,您必须写:

PreviewConfig previewConfig = new PreviewConfig.Builder().build();
Preview preview = new Preview(previewConfig);
对于较新的版本(从alpha07开始),您可以使用用例生成器来初始化用例

Preview preview = new Preview.Builder().build();
仅供参考,您使用的文档使用的是camerax core的beta01版本,您可能希望更新到该版本,而不是使用alpha06