未解决的参考:requireLensFacing | Android Studio

Dev Tyagi

我正在获取“未解决的参考:requireLensFacing” CameraSelector.Builder.requireLensFacing(lensFacing).build()

我添加了相机核心依赖项,实际上可以打开CameraSelector类并在其中找到“ requireLensFacing”方法。但是我不能使用它。

这是我的应用程式gradle:

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
}

这是错误:

屏幕截图

我该如何解决这个问题?谢谢

乌萨马·阿塔夫(Usama Altaf)

您应该像这样
val cameraSelector = CameraSelector.Builder().requireLensFacing(lensFacing).build()
使用Builder它,将其替换为Builder()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Android Studio未解决的参考。项目编译

未解决的参考:BR(Android Studio)

Android Studio和Kotlin:未解决的参考:也

android studio, kotlin 中未解决的参考 android

Android Studio:未解决的参考:box_three_text

未解决的参考,测试范围错误-Android Studio 3.5

Android Studio 3.4.2-未解决的参考v7

Android Studio Kotlin数据绑定:BR上未解决的参考

Android Studio 3.4.1,Kotlin“未解决的参考:mutableListOf”

Android Studio-Kotlin Project的“未解决的参考”问题

Android Studio中未解决的参考问题

未解决的参考:android

Android Studio“从不使用变量”,但实际上已使用(BigInteger问题,未解决的参考)

Android Studio 3.0未解决的参考:Dialogflow(api.ai)中AIConfiguration类的SupportedLanguages

未解决的参考:可在Android Studio 3.4中观察到

Kotlin Android studio 我得到一个未解决的参考

Android Kotlin:未解决的参考

Android Studio 3.4.2未解析的参考android.os.Bundle

未解决的参考:Kotlin Android中的ContextCompat

Android未解决的参考:findNavController错误

未解决的参考:viewModelScope-Android KTX

Android错误:未解决的参考:utils

Android / Kotlin:未解决的参考:木材

Android导航组件未解决的参考

Android数据绑定库-未解决的参考

未解决的参考layoutInflater Android视图绑定

未解决的参考:viewModelScope - Kotlin Android

Android Studio未运行

Android Studio 未启动