找不到 android.security.identity.IdentityCredential 的类文件

vjr*_*vjr 3 android build.gradle androidx android-biometric-prompt

作为我的应用程序中身份验证的一部分,我正在尝试实施生物识别身份验证。

我根据文档进行了所需的代码更改。

在构建我的应用程序时,我面临以下构建错误。

找不到 android.security.identity.IdentityCredential 的类文件

请在下面找到 build.gradle 文件。

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.vj.togetheron"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {


    //implementation "androidx.security:security-crypto:1.0.0-rc03"

    // For Identity Credential APIs
    //implementation "androidx.security:security-identity-credential:1.0.0-alpha01"
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.biometric:biometric:1.1.0-beta01'
    implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
    //implementation "androidx.security:security-identity-credential:1.0.0-alpha01"
    //implementation 'androidx.security:security-crypto:1.1.0-alpha02'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Run Code Online (Sandbox Code Playgroud)

请有人告诉我在这里缺少什么?

小智 5

android.security.identity.IdentityCredential 仅从 API 级别 30 开始可用。

通过为我的主项目从源代码编译的所有库进行设置compileSdkVersion 30,我已经能够解决此错误。build.gradle

由于某些未知原因,当我为主项目设置“compileSdkVersion 30”但一个库在其 build.gradle 中仍包含“compileSdkVersion 29”时,android-29 sdk 路径用于编译主项目。:(