20

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.

Vansh Arora
  • 392
  • 2
  • 13

2 Answers2

62

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

Traendy
  • 1,423
  • 15
  • 17
  • I got 'implementation "androidx.biometric:biometric:1.0.0-rc01"' and it didn't work, when changed to rc implementation it helped – natansalda Oct 28 '21 at 12:06
  • The dependency is upgraded to -- implementation 'androidx.biometric:biometric:1.2.0-alpha04' – Raj Kanchan Jun 24 '22 at 14:04
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'
Himanshi Thakur
  • 2,077
  • 14
  • 32
Raja Mali
  • 15
  • 5