我在
Android上有一个项目,minSDK = 17,targetSDK = 23.我们在这个项目中使用FingerprintManager类进行了指纹认证(它在SDK23中添加).我们添加了SDK版本检查,因此如果SDK< 23,我们不会使用与指纹相关的任何内容.但在较旧的SDK版本中,应用程序的行为是不可预测的:在某些版本的应用程序上只是崩溃,在其他版本上 - 指纹无法正常工作(所以,没关系). 我的问题: 1)minSDK = 17的任何好的且易于实现的库可以识别指纹吗?
2)如何避免SDK <23的设备中的应用崩溃?
崩溃错误:
E/dalvikvm: Could not find class 'android.hardware.fingerprint.FingerprintManager', referenced from method nl.intratuin.LoginActivity.loginByFingerprint
E/AndroidRuntime: FATAL EXCEPTION: main java.lang.VerifyError:
LoginActivity at java.lang.Class.newInstanceImpl(Native Method)
try {
keyStore.load(null);
SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME,
null);
cipher.init(Cipher.ENCRYPT_MODE, key);
return true;
} catch (KeyPermanentlyInvalidatedException e) {
return false;
} catch (KeyStoreException | CertificateException
| UnrecoverableKeyException | IOException
| NoSuchAlgorithmException | InvalidKeyException e) {
throw new RuntimeException("Failed to init Cipher", e);
}
第一个阻止整个应用程序错误我上面提到的错误.当然,我可以删除此catch(此异常扩展InvalidKeyException,因此将被处理),并在出现任何异常时返回false.这有更好的方法吗?