USE_FINGERPRINT is deprecated in API level 28
Solution 1
I've faced the same problem, imho the short answer is to ignore the deprecation, as long as you only want to support fingerprint authentication in your app.
As stated in the google dev blog, since API 28 google comes up with the new biometrics API, which simplifies the whole process of biometrics authentication. They provide a simple builder for the auth-dialog. Additionally, they support face and iris detection, too - imho it is just a matter of time if you want to support it and probably might be worth upgrading it.
The only disadvantage I've discovered so far is that if you want to check if e.g. fingerprint hardware is available, you'll have to start the authentication process to check this out and wait for the error callback. The deprecated fingerprint API instead provides methods like isHardwareDetected()
or hasEnrolledFingerprints()
for this purpose. In this case, you would probably have to re-design your application, if you rely on this information. The reason for the deprecation of those methods is probably, that it only supports fingerprints, therefore it is not a bad idea to upgrade it.
Google has also provided the compat 'androidx.biometric:biometric:1.0.0-alpha02'
version for the devices below API 28, it seems that by importing this dependency, you could simply switch to USE_BIOMETRIC
permission without modifying anything else in your app - you won't be bothered by the warning anymore. Since it is only in alpha stage, I would use it with care. Therefore, as long as you don't use anything from the biometrics API, you could also simply ignore the problem and face it again when you want to support additional biometric authentication methods.
EDIT: Now, the beta version of compat library is released, 'androidx.biometric:biometric:1.0.0-beta01'
. For more info on this, check here.
Now, the stable version of compat library is released on December 18, 2019, 'androidx.biometric:biometric:1.0.1'. For more info on this Click here.
Solution 2
biometrics API provides BiometricConstants for error handling
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
//The device does not have a biometric sensor.
if (errorCode == BiometricPrompt.ERROR_HW_NOT_PRESENT){
//Do something
}
}
Comments
-
JerabekJakub almost 2 years
Constant
USE_FINGERPRINT
was deprecated in API level 28 and we should use more genericUSE_BIOMETRIC
which has been added in same API level.I swap these constants in my Manifest and I'm getting error when calling
FingerprintManagerCompat.from(context).isHardwareDetected()
.Error is:
Missing required permission - USE_FINGERPRINT
This happens because of
@RequiresPermission("android.permission.USE_FINGERPRINT")
annotation inFingerprintManagerCompat
in 28.0.0-rc3 support v4 lib.Is this something I can ignore and continue using new permission?
-
jungledev over 5 yearsThis is the kind of quality answer we need more of on stack overflow. +100 <3. Too bad @JerabekJakub hasn't yet selected your answer as the official one to give you the points you deserve.
-
JerabekJakub almost 5 years@jungledev In my defense, SO didn't send me notification to inbox to Mathew11's answer neither to your comment. I received notification only after new answer from 16/8 a then I saw this answer and your comment. :-/
-
Sergio almost 5 years"1.0.0-beta02" now available, still waiting for final version.
-
Florian Walther over 4 yearsOn 29, there's
canAuthenticate
developer.android.com/reference/android/hardware/biometrics/…