android - 未解决的参考:requireLensFacing | 安卓工作室
问题描述
我收到“未解决的参考:requireLensFacing”CameraSelector.Builder.requireLensFacing(lensFacing).build()
我添加了相机核心依赖项,实际上我可以打开 CameraSelector 类并在其中找到“requireLensFacing”方法。但我就是不能用。
这是我的应用程序等级:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.devtyagi.facemaskdetector"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures{
mlModelBinding true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
implementation 'com.google.android.material:material:1.2.1'
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
implementation "androidx.camera:camera-view:1.0.0-alpha20"
implementation "androidx.camera:camera-extensions:1.0.0-alpha20"
implementation "org.tensorflow:tensorflow-lite-metadata:${tflite}"
implementation "org.tensorflow:tensorflow-lite-gpu:2.2.0"
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0-rc1'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
这是我的项目级 gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.21"
ext.tflite = "0.1.0-rc1"
ext.camerax_version = "1.0.0-rc01"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是错误:
我该如何解决这个问题?谢谢你
解决方案
你应该像这样使用它,val cameraSelector = CameraSelector.Builder().requireLensFacing(lensFacing).build()
你正在使用Builder
替换它Builder()
推荐阅读
- linux - 系统 cron 未运行计划执行的预期进程
- angular - Angular canActive() 不返回值?
- matlab - 如何从matlab中的向量中选择特定百分比的项目?
- php - 带有子类别的结论类别
- javascript - 我可以在 React Storybook 中创建一个旋钮来修改具有 4 个值的数组,其中每个值都有一个选择下拉列表吗?
- r - 将月度数据转换为 R 中的按日表
- mysql - Laravel 分页不会重新初始化 MySQL 变量
- html - 如何使用Javascript一次只选择两个连续的复选框
- ios - 较小尺寸的uiviewcontroller
- r - 将带引号的字符串放在 rlang 函数中的正确方法是什么?