Android BiometricPrompt: Cannot resolve symbol PromptInfo
Asked Answered
A

2

22

When I copied the following code from this developer.android.com tutorial about adding biometric authentication in your android app:

BiometricPrompt.PromptInfo promptInfo =
            new BiometricPrompt.PromptInfo.Builder()
            .setTitle("Biometric login for my app")
            .setSubtitle("Log in using your biometric credential")
            .setNegativeButtonText("Cancel")
            .build();

PromptInfo is not recognized.

I have followed all the steps prior to this in the tutorial.

Allanallana answered 16/10, 2019 at 17:9 Comment(1)
Do you add the dependency in your build.gradle file?Salish
R
64

You need to add this dependency:

implementation 'androidx.biometric:biometric:1.0.0-rc01'

And make sure you use this import:

import androidx.biometric.BiometricPrompt;

and not

import android.hardware.biometrics.BiometricPrompt;

Update: for the current version check: https://mvnrepository.com/artifact/androidx.biometric/biometric?repo=google

Rhesus answered 16/10, 2019 at 17:22 Comment(2)
I got 'implementation "androidx.biometric:biometric:1.0.0-rc01"' and it didn't work, when changed to rc implementation it helpedBairam
The dependency is upgraded to -- implementation 'androidx.biometric:biometric:1.2.0-alpha04'Nusku
T
0
private BiometricPrompt.PromptInfo promptInfo;

Add these dependencies in the app level gradle file :

 implementation "androidx.biometric:biometric:1.1.0"
 implementation 'androidx.biometric:biometric:1.2.0-alpha05'
Tectonic answered 7/4, 2023 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.