4

I'm trying to use BiometricPrompt for fingerprint authentication in my Android App. There are no errors in my code, but when I run it:

java.lang.BootstrapMethodError: Exception from call site #3 bootstrap method

This is my Activity:

 package com.arfmann.accountmanager

import androidx.biometric.*
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity
import kotlinx.android.synthetic.main.activity_fingerprint.*
import java.util.concurrent.Executors

class FingerprintActivity : AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_fingerprint)

        val executor = Executors.newSingleThreadExecutor()
        val activity: FragmentActivity = this // reference to activity
        val biometricPrompt = BiometricPrompt(
            activity,
            executor,
            object : BiometricPrompt.AuthenticationCallback() {

                override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
                    super.onAuthenticationError(errorCode, errString)
                    if (errorCode == BiometricPrompt.ERROR_NEGATIVE_BUTTON) {
                        // user clicked negative button
                    } else {
                        TODO("Called when an unrecoverable error has been encountered and the operation is complete.")
                    }
                }

                override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
                    super.onAuthenticationSucceeded(result)
                    TODO("Called when a biometric is recognized.")
                }

                override fun onAuthenticationFailed() {
                    super.onAuthenticationFailed()
                    TODO("Called when a biometric is valid but not recognized.")
                }
            })

        val promptInfo = BiometricPrompt.PromptInfo.Builder()
            .setTitle("Set the title to display.")
            .setSubtitle("Set the subtitle to display.")
            .setDescription("Set the description to display")
            .setNegativeButtonText("Negative Button")
            .build()

        authenticateButton.setOnClickListener {
            biometricPrompt.authenticate(promptInfo)
        }
    }
}

This is the full error:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.arfmann.accountmanager, PID: 21973 java.lang.BootstrapMethodError: Exception from call site #3 bootstrap method at androidx.biometric.BiometricFragment.(BiometricFragment.java:86) at androidx.biometric.BiometricFragment.newInstance(BiometricFragment.java:187) at androidx.biometric.BiometricPrompt.authenticateInternal(BiometricPrompt.java:681) at androidx.biometric.BiometricPrompt.authenticate(BiometricPrompt.java:658) at com.arfmann.accountmanager.FingerprintActivity$onCreate$1.onClick(FingerprintActivity.kt:52) at android.view.View.performClick(View.java:6663) at android.view.View.performClickInternal(View.java:6635) at android.view.View.access$3100(View.java:794) at android.view.View$PerformClick.run(View.java:26199) at android.os.Handler.handleCallback(Handler.java:907) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7625) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) Caused by: java.lang.ClassCastException: Bootstrap method returned null at androidx.biometric.BiometricFragment.(BiometricFragment.java:86)  at androidx.biometric.BiometricFragment.newInstance(BiometricFragment.java:187)  at androidx.biometric.BiometricPrompt.authenticateInternal(BiometricPrompt.java:681)  at androidx.biometric.BiometricPrompt.authenticate(BiometricPrompt.java:658)  at com.arfmann.accountmanager.FingerprintActivity$onCreate$1.onClick(FingerprintActivity.kt:52)  at android.view.View.performClick(View.java:6663)  at android.view.View.performClickInternal(View.java:6635)  at android.view.View.access$3100(View.java:794)  at android.view.View$PerformClick.run(View.java:26199)  at android.os.Handler.handleCallback(Handler.java:907)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:216)  at android.app.ActivityThread.main(ActivityThread.java:7625)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

I've added the right dependence to my build.gradle:

    implementation 'androidx.biometric:biometric:1.0.0-beta01'
THIS HAPPENS ONLY IN BETA-01, IN ALPHA-03 WORKS FINE
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Arfmann
  • 684
  • 9
  • 30
  • When you say alpha-03 are you also saying you didn't include the 'canAuthenticate()' method of the non-existent BiometricManager class? – Vijay Kumar Kanta Sep 08 '19 at 03:44
  • Exactly, because I'm using it with androidx library. Biometric Manager is avaible on androidx only with beta 01 – Arfmann Sep 08 '19 at 10:24

2 Answers2

3

Set Java 8 in build.gradle

compileOptions {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}
dreinoso
  • 1,479
  • 17
  • 26
2

We're aware of this issue and have addressed this issue in the beta02 release, which is being released around September 18

The library has been updated to not use lambdas.

Kevin
  • 168
  • 11