我在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)
Run Code Online (Sandbox Code Playgroud)
一些新信息:使用本教程创建HelloWorld指纹项目:http: //www.techotopia.com/index.php/An_Android_Fingerprint_Authentication_Tutorial 找到问题的根源:FingerprintDemoActivity-> cipherInit:
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); …Run Code Online (Sandbox Code Playgroud)