androidcannot-find-symbolandroid-biometric-prompt

Android BiometricPrompt: Cannot resolve symbol PromptInfo


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.


Solution

  • 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