Reputation: 7166
I'm trying to get biometrics authentication to work again after updating the app I'm developing. But I'm constantly getting the same error when activating it:
PlatformException(NotAvailable, Required security features not enabled, null, null)
The current one in the store has no problems at all.
I'm using local_auth: 1.1.4
MainActivity.java has been converted to a FragmentedActivity
I'm doing a simple check to see if the biometrics are available. Which they are
bool canCheckBiometrics = await auth.canCheckBiometrics;
List<BiometricType> availableBiometrics =
await auth.getAvailableBiometrics();
print(canCheckBiometrics); //Returns true
print(availableBiometrics.toString()); //Returns [BiometricType.fingerprint]
After that I try to do the authentication
try {
authenticated = await auth.authenticate(
biometricOnly: true,
localizedReason: 'Login with biometrics',
useErrorDialogs: true,
stickyAuth: false);
} on PlatformException catch (e) {
print(e);
}
This returns:
PlatformException(NotAvailable, Required security features not enabled, null, null)
And this is what the plugin comments in the code say.
// Indicates the device does not have a Touch ID/fingerprint scanner.
const String notAvailable = 'NotAvailable';
I'm not really sure what to check anymore. Is this something new I need to be aware of?
Really hope someone can help me with this issue!
Hope to hear!
Upvotes: 11
Views: 11508
Reputation: 934
First of all, you need to add a biometric authentication method to your device from settings.
For example if you are using Pixel 2 API 32 as Android Emulator,
Similarly, if you are trying with a real device or another emulator, you need to enable fingerprint authentication and try again.
Upvotes: 8
Reputation: 120
I had the same issue and after debugging I discovered that keyguardManager was always null and causing the plugin to throw not enable exception. I had to change the below method in LocalAuthPlugin as follows:
private boolean isDeviceSupported()
{
if (keyguardManager == null) return false;
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
keyguardManager.isDeviceSecure());
}
to
private boolean isDeviceSupported()
{
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
}
It worked for me, hopefully will work for you and others.
Upvotes: 0
Reputation: 887
Go to settings -> security -> fingerprint and add fingerprint lock.
If you are using Android studio emulator then keep in mind that Android Studio emulator provides fake fingerprint scanning.
Upvotes: 2
Reputation: 492
I recommend that you verify all capabilities before of try authenticate the user.
Future<bool> authenticateIsAvailable() async {
final isAvailable = await localAuth.canCheckBiometrics;
final isDeviceSupported = await localAuth.isDeviceSupported();
return isAvailable && isDeviceSupported;
}
This way, you can call localAuth.authenticate
only for phones that have credentials enrolled and probably don't have exceptions. Even though, catch the error if possible.
Upvotes: 7
Reputation: 11
I think you don't have a fingerprint activated yet, or you don't have permissions to use it, check the permissions and try again.
Check this out:
Upvotes: 1