omadahealth / LolliPin

A Material design Android pincode library. Supports Fingerprint.
MIT License
1.6k stars 426 forks source link

Null Pointer Exception on android.hardware.fingerprint.FingerprintManager.isHardwareDetected() #195

Open abumoallim opened 5 years ago

abumoallim commented 5 years ago

I am getting null pointer exception on Xiomi Mobile particularly.

I am using Lollipin for 6 months. This has recently occurred in Xiomi phone. Though it works on other phones.

I would like to know if any possible solution for this.

I am posting detail of error and Device details :

Fatal Exception: java.lang.RuntimeException Unable to resume activity {.CustomPinActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.hardware.fingerprint.FingerprintManager.isHardwareDetected()' on a null object reference

Android : 8.1.0 and Mobile : Xiomi Redmi 6A .

yar1k0v commented 5 years ago

Up, I got the same issue with the library ver. 2.0

yar1k0v commented 5 years ago

The cause of this exception is that on many devices the FingerprintManager is not accessible (the reference is null) and to access it you need a vendors SDK installed with its own libraries set. The quick solution here is to add a null check inside FingerprintUiHelper.isFingerprintAuthAvailable() (line number 222) method on the FingerprintManager class right before calling any method on it.