BiometricPrompt Executor and/or callback was null

fingerprint dialog android
fingerprint authentication
google biometric authentication
android face unlock api
android biometric password
biometric login
biometric credentials
how to implement face recognition authentication in android

I'm using BiometricPrompt from androidx.biometric:biometric:1.0.0-beta02 for the authenticate process. But i face very strange problem.

First time i call biometricsPromt.authenticate() everything works fine, the library shows me the screen depending what security method is set(pattern,fingerprint, password and etc…) then the callback is called and everything is good.

The problem is when i call biometricsPromt.authenticate() for the second time i got the error:

E/DeviceCredentialHandler: onCreate: Executor and/or callback was null!

I'm passing executor and callback of course -> they are not null

Does anyone face the same problem or have some idea what can be the problem?

This is how i'm creating the BiometricPromt

`

companion object {
        private val executor: Executor by lazy {
            Executors.newSingleThreadExecutor()
        }

        fun showBiometricsPrompt(
            activity: FragmentActivity,
            callback: BiometricPrompt.AuthenticationCallback
        ): BiometricPrompt {
            val promptInfo = BiometricPrompt.PromptInfo.Builder()
                .setTitle(activity.getString(R.string.title_authentication))
                .setDescription(activity.getString(R.string.msg_authenticate_first))
                .setDeviceCredentialAllowed(true)
                .build()

            val biometricPrompt =
                BiometricPrompt(
                    activity,
                    executor, callback
                )
            biometricPrompt.authenticate(promptInfo)
            return biometricPrompt
        }

`

And here is how i called:

`

BiometricsHelper.showBiometricsPrompt(
                this,
                object : BiometricPrompt.AuthenticationCallback() {
                    override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
                        super.onAuthenticationError(errorCode, errString)

                        showToastMsg(errString.toString())
                    }

                    override fun onAuthenticationFailed() {
                        super.onAuthenticationFailed()
                    }

                    override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
                        super.onAuthenticationSucceeded(result)

                    }
                })

`


Here's a work around this problem, but not a complete fix.

You need to call recreate() after you finish doing whatever you set out to do after the authentication.

This will restart the activity and allow the biometric prompt to be shown again.

BiometricPrompt, CancellationSignal : An object that can be used to cancel authentication. This value cannot be null . executor, Executor : An executor to handle callback events. public BiometricPrompt (FragmentActivity fragmentActivity, Executor executor, BiometricPrompt.AuthenticationCallback callback) As a required parameter, we need executor to handle callback events


What device are you testing on? Can you file a bug on the public issuetracker here with both

  1. adb bugreport foo.zip
  2. ideally a .zip of a sample app that reproduces the issue?

biometric/src/main/java/androidx/biometric , Log.e(TAG, "onCreate: Executor and/or callback was null!"); } else {. // (Re)​connect to and launch a biometric prompt within this activity. final BiometricPrompt  The AndroidX BiometricPrompt needs 4 components to work: A fragment or activity that provides the context for the prompt, an AuthenticationCallback through which we get our authentication result, an executor that defines on which thread this callback runs on, and a PromptInfo object that contains the metadata and configurations for our


It seems it is related to this line: .setDeviceCredentialAllowed(true)

If I change that to false, it works every time without re-creating the activity

core/java/android/hardware/biometrics/BiometricPrompt.java , CallbackExecutor; public class BiometricPrompt implements BiometricAuthenticator, throw new IllegalArgumentException("Executor must not be null");. BiometricPrompt(FragmentActivity fragmentActivity, java.util.concurrent.Executor executor, BiometricPrompt.AuthenticationCallback callback) Constructs a BiometricPrompt which can be used to prompt the user for authentication. public: BiometricPrompt(Fragment fragment, java.util.concurrent.Executor executor, BiometricPrompt


Fingerprint Authentication using BiometricPrompt Compat, BiometricPrompt.AuthenticationCallback callback). As a required parameter, we need executor to handle callback events. So, let's create one: crypto— canbe null, if a fingerprint is used in decryption then this object should contain a proper cipher cancel— this object can stop listening on the authentication events, in this case it will


BiometricsPrompt full implementation · GitHub, private val executor = MainThreadExecutor(). override fun activity,. executor,. object : BiometricPrompt.AuthenticationCallback() { null) : Exception(message). */ public BiometricPrompt (@NonNull FragmentActivity fragmentActivity, @NonNull Executor executor, @NonNull AuthenticationCallback callback) The third parameter: AuthenticationCallback is an abstract static class with three non-abstract methods, so technically we won't have to override any of them.


Securing data with BiometricPrompt, The main class involved in the biometric prompt is, what a surprise, called androidx.biometric. @param executor An executor to handle callback events. toByteArray(), null) val cleartext = aead.decrypt(encrypted, null). But, in Android 9.0(P) it is deprecated and releases a new API called BiometricPrompt (android.hardware.biometrics.BiometricPrompt). Question: Does it means we have to use the FingerprintManager from Android 23+ to 28 and BiometricPrompt in Android P?