Biometric

Authenticate with biometrics or device credentials, and perform cryptographic operations.
Latest Update Stable Release Release Candidate Beta Release Alpha Release
August 7, 2024 1.1.0 - - 1.4.0-alpha02

Declaring dependencies

To add a dependency on Biometric, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    // Java language implementation
    implementation "androidx.biometric:biometric:1.1.0"

    // Kotlin
    implementation "androidx.biometric:biometric-ktx:1.4.0-alpha02"
}

Kotlin

dependencies {
    // Java language implementation
    implementation("androidx.biometric:biometric:1.1.0")

    // Kotlin
    implementation("androidx.biometric:biometric:1.4.0-alpha02")
}

For more information about dependencies, see Add Build Dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 1.4

Version 1.4.0-alpha02

August 7, 2024

androidx.biometric:biometric:1.4.0-alpha02 and androidx.biometric:biometric-ktx:1.4.0-alpha02 are released. Version 1.4.0-alpha02 contains these commits.

New Features

  • PromptContentView allows developers to show the custom content view as an additional option of plain description text view
  • App logo on Biometric Prompt is shown - automatically added using application icon.

API Changes

  • Add APIs to support custom content view
    • BiometricPrompt.PromptInfo.Builder#setContentView
    • BiometricPrompt.PromptInfo#getContentView
    • PromptContentView interface
    • PromptVerticalListContentView class
    • PromptContentViewWithMoreOptionsButton class (for privileged apps only)
  • Add APIs to support logo (for privileged apps only)
    • BiometricPrompt.PromptInfo.Builder#setLogoBitmap
    • BiometricPrompt.PromptInfo.Builder#setLogoRes
    • BiometricPrompt.PromptInfo.Builder#setLogoDescription
    • BiometricPrompt.PromptInfo#getLogoBitmap
    • BiometricPrompt.PromptInfo#getLogoRes
    • BiometricPrompt.PromptInfo#getLogoDescription 58c35c6

Bug Fixes

Version 1.4.0-alpha01

May 29, 2024

androidx.biometric:biometric:1.4.0-alpha01 and androidx.biometric:biometric-ktx:1.4.0-alpha01 are released. This version is developed in an internal branch and targets Android 15 Beta 2.

Bug Fixes

  • Update UI to be consistent with platform changes in Android 15

Version 1.2.0

Version 1.2.0-alpha05

September 21, 2022

androidx.biometric:biometric:1.2.0-alpha05 and androidx.biometric:biometric-ktx:1.2.0-alpha05 are released. Version 1.2.0-alpha05 contains these commits.

API Changes

  • Added CryptoObject support for android.security.identity.PresentationSession in Android 13. (C5f1ec, b/197965513)

Bug Fixes

  • Removed unnecessary resource variants to reduce library size. (I3601e, b/220178553)
  • Fixed issue for BiometricPrompt hosted in non-activity contexts. (Ife255)

Version 1.2.0-alpha04

November 17, 2021

androidx.biometric:biometric:1.2.0-alpha04 and androidx.biometric:biometric-ktx:1.2.0-alpha04 are released. Version 1.2.0-alpha04 contains these commits.

New Features

  • Improved BiometricPrompt support for fragments that are hosted by non-activity contexts (I9312b)

API Changes

Bug Fixes

  • Fixed an issue on API 29 where some devices (including emulators) would receive a cancellation error when falling back to PIN/pattern/password. Note that, for some devices on API 29, this may cause the user to be prompted for their screen lock even if a biometric is available and enrolled. (b/142740104)
  • Fixed an issue on API 29 where devices with no biometric hardware would not correctly fall back to PIN/pattern/password (b/170517889)

Version 1.2.0-alpha03

February 24, 2021

androidx.biometric:biometric:1.2.0-alpha03 and androidx.biometric:biometric-ktx:1.2.0-alpha03 are released. Version 1.2.0-alpha03 contains these commits.

API Changes

  • Added suspending coroutine extensions for CredentialAuthPrompt similar to those that exist for other AuthPrompt types. (I9ac70)

Version 1.2.0-alpha02

January 27, 2021

androidx.biometric:biometric:1.2.0-alpha02 and androidx.biometric:biometric-ktx:1.2.0-alpha02 are released. Version 1.2.0-alpha02 contains these commits.

API Changes

  • Refactored some AuthPrompt fields that were previously set via a builder into startAuthentication(...) method arguments. (I18896, b/174098373)
  • Added minimum API level requirements for AuthPrompt types with limited or no support on older Android versions. (I18896)
  • Added getter methods for all AuthPrompt fields that are set via a builder. (I18896)
  • Added suspending coroutine Kotlin extensions for biometric authentication via the AuthPrompt APIs. These functions will return the AuthenticationResult directly on success or throw an exception on error or failure (credential rejection). (Iffc9e)

Bug Fixes

  • Fixed an issue where BiometricManager.canAuthenticate(int) would sometimes return the wrong status code for a device with a fingerprint sensor on Android 10 (API level 29). (I72420, b/176921662)
  • Fixed an issue where BiometricManager.canAuthenticate(int) would return the wrong status code for a device with no biometric hardware and no enrolled PIN, pattern, or password on Android 10 (API level 29) and prior SDK versions. (I79b7d, b/174505824)
  • Fixed a memory leak that would occur when BiometricPrompt was hosted in a fragment with a shorter lifecycle than its associated activity. (I70864, b/167014923)

Version 1.2.0-alpha01

December 2, 2020

androidx.biometric:biometric:1.2.0-alpha01 and androidx.biometric:biometric-ktx:1.2.0-alpha01 are released. Version 1.2.0-alpha01 contains these commits.

New Features

  • Introduced the androidx.biometric:biometric-ktx module, which adds Kotlin-specific APIs and extensions on top of androidx.biometric:biometric.

API Changes

  • Added new AuthPrompt APIs for constructing a BiometricPrompt and performing authentication. These APIs do not require the BiometricPrompt to be constructed in an early lifecycle callback, such as onCreate. (I19022)
  • Added Kotlin extensions to Fragment and FragmentActivity for the new AuthPrompt APIs. (Iaf98c)

Version 1.1.0

Version 1.1.0

January 27, 2021

androidx.biometric:biometric:1.1.0 is released. Version 1.1.0 contains these commits.

Major changes since 1.0.0

  • Added backwards-compatible support for new biometric authentication features and API updates introduced in Android 11.
  • Significantly reduced the app size footprint of the library (by >100 KB, in some cases).
  • Removed various sources of memory leaks that were previously caused by the library.
  • Fixed class verification failures that could affect performance on older Android versions.
  • Made various additional improvements to the stability and behavior of the library.

Version 1.1.0-rc01

November 11, 2020

androidx.biometric:biometric:1.1.0-rc01 is released. Version 1.1.0-rc01 contains these commits.

Bug Fixes

  • Fixed an issue on some devices where certain actions (authenticating, canceling, etc.) would sometimes throw a NullPointerException. (b/151316421)
  • Fixed an issue where some Pixel devices would report the wrong status when using BiometricManager#canAuthenticate(int) to check for Class 3 biometrics on Android 10. (b/170406186)

Version 1.1.0-beta01

October 1, 2020

androidx.biometric:biometric:1.1.0-beta01 is released. Version 1.1.0-beta01 contains these commits.

New Features

  • Significantly reduced the library's APK size footprint (by >100 KB compressed, in some cases) by replacing dialog animations with static assets on Android 8.1 and earlier. (I4844e)
  • BiometricPrompt now automatically falls back to device credential authentication (if allowed) on all supported Android versions when biometric authentication is locked out. (b/149579143)

Bug Fixes

  • Fixed an issue where BiometricPrompt caused a crash on some Android 9 devices without a fingerprint sensor. (b/151443237)
  • Fixed a potential NullPointerException in FingerprintDialogFragment. (b/167951429)
  • Fixed an issue where the wrong CryptoObject type was used for a reflective method invocation in BiometricManager. (b/165824669)
  • Fixed an issue where showing BiometricPrompt again shortly after dismissal caused the new prompt to be dismissed automatically on some Android 10 devices. (b/157783075)
  • Fixed memory leaks related to the use of FingerprintManagerCompat. (b/165840273)
  • Fixed issues with the fingerprint dialog UI being hidden or shown incorrectly on some Android 9 devices. (b/154868505, b/148350291)

Version 1.1.0-alpha02

August 19, 2020

androidx.biometric:biometric:1.1.0-alpha02 is released. Version 1.1.0-alpha02 contains these commits.

New Features

  • BiometricManager#canAuthenticate() may now return BIOMETRIC_STATUS_UNKNOWN to indicate that the user may still be able to authenticate, or BIOMETRIC_ERROR_UNSUPPORTED to indicate that a given authenticator combination is not supported by the device.
  • BiometricPrompt#authenticate() may now be used for device credential authentication with an associated CryptoObject on Android 11 (API level 30) and above only.

API Changes

Bug Fixes

  • Fixed memory leaks reported by LeakCanary in BiometricFragment and BiometricViewModel. (b/144919472)
  • Ensured that BiometricViewModel will no longer call MutableLiveData#setValue() from a background thread. (b/159983244)
  • Fixed an issue where BiometricPrompt was not correctly handling temporary lockout on some API levels. (9acfce9)
  • Fixed an issue where BiometricPrompt would return the wrong error code for a device not secured with a screen lock credential on some API levels. (b/148626482)
  • Fixed an issue where BiometricManager and BiometricPrompt would return the wrong error codes for a device with no keyguard implementation on some API levels. (891c6e0)

Version 1.1.0-alpha01

June 24, 2020

androidx.biometric:biometric:1.1.0-alpha01 is released. Version 1.1.0-alpha01 contains these commits.

New Features

  • Refactored the internal library implementation to address potential sources of memory leaks and other unintended behavior:
    • Internal fragments now share and persist data using a ViewModel that is tied to the client application's activity lifecycle.
    • Device credential authentication prior to Android 10 (API level 29) no longer starts a transparent activity within the client application.

Bug Fixes

  • Resolved deprecation warnings related to the use of FingerprintManagerCompat. (b/142967618)
  • Changed how SDK-gated platform methods are called to avoid class verification issues on older Android versions. (94beb4b)
  • Gradle dependencies that are not part of the public API are no longer exported by the library. (f289d9e)

Version 1.0.1

Version 1.0.1

December 18, 2019

androidx.biometric:biometric:1.0.1 is released. Version 1.0.1 contains these commits.

Bug fixes

  • Extended the existing fingerprint fallback workaround for crypto-based authentication to known affected vendors, while also limiting it to API 28 (b/143361271)
  • Fixed an issue on certain devices where the biometric dialog was shown under a system overlay (b/143230260)
  • Fixed several issues with setDeviceCredentialAllowed(true) (b/143091227, b/143097321, b/143653944)
  • Fixed an issue on certain Android versions where onAuthenticationSuccess was not always called after the user confirmed their device credential (b/145232806)
  • Fixed an issue on certain Android versions where onAuthenticationError was not always called when the prompt was dismissed on rotation (b/145230042)
  • Fixed an issue on certain Android versions where the prompt was not dismissed when receiving certain error codes (b/143683687)
  • Fixed a potential NullPointerException in BiometricFragment (b/142599311)

Version 1.0.0

Version 1.0.0

November 7, 2019

androidx.biometric:biometric:1.0.0 is released with no changes since 1.0.0-rc02. Version 1.0.0 contains these commits.

Major features of 1.0.0

  • Compatibility version of the BiometricPrompt and BiometricManager APIs, as implemented in Android 10, with full feature support back to Android 6.0 (API 23)
  • Built-in lifecycle management for BiometricPrompt within a Fragment or FragmentActivity
  • Special handling for devices known to incorrectly present weak biometrics during crypto-based authentication

Version 1.0.0-rc02

October 23, 2019

androidx.biometric:biometric:1.0.0-rc02 is released. Version 1.0.0-rc02 contains these commits.

Bug fixes

  • Added a workaround for certain devices that are known to incorrectly provide a weak biometric when crypto-based authentication is invoked on API versions 28 and 29 (b/142150327)

Version 1.0.0-rc01

October 9, 2019

androidx.biometric:biometric:1.0.0-rc01 is released. Version 1.0.0-rc01 contains these commits.

Bug fixes

  • Fixed a potential crash with FingerprintDialogFragment when dismissing it while the screen is rotating (b/141356362)
  • Fixed an issue where receiving a null AuthenticationResult from the framework API could cause a crash (b/138862251)
  • Fixed crashes caused by BiometricPrompt being dismissed after onSaveInstanceState() (b/138825362, b/140447194)

Version 1.0.0-beta02

September 18, 2019

androidx.biometric:biometric:1.0.0-beta02 is released. Version 1.0.0-beta02 contains these commits.

Bug fixes

  • Fixed issues with device credential support in version 1.0.0-beta01
  • Removed Java 8 dependencies and switched to depending on Java 7 (b/140508526)
  • FingerprintHelperFragment now correctly throws ERROR_HW_NOT_PRESENT when no fingerprint hardware is detected (b/140427586)

Version 1.0.0-beta01

August 29, 2019

androidx.biometric:biometric:1.0.0-beta01 is released. Version 1.0.0-beta01 contains these commits.

New features

We’ve introduced a second constructor for BiometricPrompt that allows it to be hosted in a Fragment (as opposed to the existing constructor, which requires a FragmentActivity).

We’re also excited to bring the following functionality from Android 10 to the AndroidX Biometric library:

  1. BiometricManager#canAuthenticate
  2. BiometricPrompt.PromptInfo#setConfirmationRequired
  3. BiometricPrompt.PromptInfo#setDeviceCredentialAllowed

On Android 10, the library will invoke the corresponding methods from the platform API. On older API levels, the library will emulate the behavior.

API changes

  • Added fragment-specific constructor for biometric prompt (b/131980596)
  • See the “New features” section above.

Bug fixes

  • Add BiometricPrompt device credential support for L+
  • Fixed BiometricPrompt to use public error constants (b/137788194)
  • Fix NullPointerException in BiometricPrompt.onAttach() (b/136103103)
  • Changed behavior to not allow BiometricPrompt to be cancelled by a touch event outside the prompt (b/135684487)
  • Fixed onAuthenticationError crash when a null error value is returned in Kotlin (b/128350861)
  • FingerprintDialogFragment is now style-able (b/127878106)
  • FingerprintDialog is now scrollable (b/126367887)
  • Fixed bug where rotating the biometric dialog raises an IllegalStateException (b/124153656), (b/123811924)
  • Fixed inconsistent behavior on API Levels 23 to 27. (b/124066957)
  • Fixed issue where Fingerprint Login Dialog read incorrect text using Talkback. (b/123572331)

Version 1.0.0-alpha04

April 3, 2019

androidx.biometric:biometric:1.0.0-alpha04 is released. The commits included in this version can be found here.

Bug fixes

  • Fixed Biometric fragments don't clean up in all cases. (b/121117380)
  • Fixed BiometricPrompt only allows one instance of BiometricPrompt.AuthenticationCallback (b/123857949)
  • Fixed BiometricPrompt error behavior inconsistent between system and compat versions. (b/123572326)
  • Fixed callback onAuthenticationError() with @NotNull errString causes NullPointerException at runtime (b/123167217)
  • Fixed androidx.BiometricPrompt Cancel button Crashes (b/122054485)
  • Fixed androidx.biometric.PromptInfo title/description not changed on Android P (b/122856773)

Version 1.0.0-alpha03

December 17, 2018

Bug fixes

  • Fixed fragment-related issues
  • On devices O and older, lockout errors are returned immediately to be consistent with P and above