SDK上的Android指纹<;23
我有一个关于Android的项目,minSDK=17,targetSDK=23。在这个项目中,我们使用指纹管理器类(它是在SDK23中添加的)进行指纹身份验证。我们添加了SDK版本检查,因此如果SDK回答问题的第二部分,我们不会使用任何与指纹相关的内容SDK上的Android指纹<;23,android,fingerprint,Android,Fingerprint,我有一个关于Android的项目,minSDK=17,targetSDK=23。在这个项目中,我们使用指纹管理器类(它是在SDK23中添加的)进行指纹身份验证。我们添加了SDK版本检查,因此如果SDK回答问题的第二部分,我们不会使用任何与指纹相关的内容 我想,我找到了可以接受的解决方案:捕获的不是KeyPermanentlyInvalidateException,而是InvalidKeyException。这样一切都很好。仍然不知道这个异常是如何使整个应用程序崩溃的…看看由一个名为。 如果指纹不
我想,我找到了可以接受的解决方案:捕获的不是KeyPermanentlyInvalidateException,而是InvalidKeyException。这样一切都很好。仍然不知道这个异常是如何使整个应用程序崩溃的…看看由一个名为。 如果指纹不可用,此库可以使用密码
SDK 23之前的任何设备都需要使用各自独立的基于设备制造商的SDK。这也发生在我身上..即使我使用:if(Build.VERSION.SDK\u INT>=Build.VERSION\u CODES.M)。。我的应用程序在android 4.4-kitkat上崩溃。因此,问题最终出现在catch部分的initCipher方法中——请参阅以下代码(尽管我不认为它是针对m和更高级别的对象的……非常奇怪的行为……):
很明显,这个订单是有问题的。所以一定要像我提到的那样写出来。只要按照android studio的提示,就可以了
try {
mKeyStore.load(null);
SecretKey key = (SecretKey) mKeyStore.getKey(keyName, null);
cipher.init(Cipher.ENCRYPT_MODE, key);
return true;
} catch (IOException | NoSuchAlgorithmException | CertificateException
| UnrecoverableKeyException | KeyStoreException | InvalidKeyException e) {
e.printStackTrace();
throw new RuntimeException("Failed to init Cipher", e);
}
我解决了这个问题,将所有指纹代码移动到一个helper类,这样与指纹代码相关的类就不会在活动中导入,并且只在SDK_INT大于23时实例化helper类(在我的情况下,因为我只支持Android 6+)崩溃原因:
FingerprintManager
类适用于Android版本23及更高版本
如果您的应用程序使用的是FingerprintManager
类,并且运行在较旧版本的Android上,那么您将遇到此异常
支持旧版本的Android:
如果您计划支持Android,请使用
FingerprintManagerCompat
而不是FingerprintManager
,我也遇到了这个问题。即使我使用:if(Build.VERSION.SDK\u INT>=Build.VERSION\u CODES.M)。。我的应用程序在较低的API上崩溃。我的解决办法如下:
替换这些代码:
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);
}
与:
“对于minSDK=17,是否有好的、易于实现的、能够识别指纹的库?”——任何23之前的指纹支持都是特定于制造商的。“我如何避免应用程序在SDKTried设备中崩溃,但无论如何,我的sdk 17崩溃了。你是最好的…谢谢谢谢,伙计…你真的救了我一天谢谢使用
@TargetApi(Build.VERSION\u CODES.M)
链接不可用
if (Build.VERSION.SDK_INT < 23) {
// Handle the mechanism where the SDK is older.
}else{
// Handle the mechanism where the SDK is 23 or later.
}
@TargetApi(Build.VERSION_CODES.M)
private boolean initCipher() {
try {
mKeyStore.load(null);
SecretKey key = (SecretKey) mKeyStore.getKey(KEY_NAME, null);
mCipher.init(Cipher.ENCRYPT_MODE, key);
return true;
} catch (KeyStoreException | CertificateException | UnrecoverableKeyException | IOException
| NoSuchAlgorithmException e) {
throw new RuntimeException("Failed to init Cipher", e);
} catch (InvalidKeyException e) {
e.printStackTrace();
return false;
}
}
try {
mKeyStore.load(null);
SecretKey key = (SecretKey) mKeyStore.getKey(keyName, null);
cipher.init(Cipher.ENCRYPT_MODE, key);
return true;
} catch (IOException | NoSuchAlgorithmException | CertificateException
| UnrecoverableKeyException | KeyStoreException | InvalidKeyException e) {
e.printStackTrace();
throw new RuntimeException("Failed to init Cipher", e);
}
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);
}
try {
keyStore.load(null);
} catch (CertificateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
SecretKey key = null;
try {
key = (SecretKey) keyStore.getKey(KEY_NAME,
null);
} catch (KeyStoreException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnrecoverableKeyException e) {
e.printStackTrace();
}
try {
cipher.init(Cipher.ENCRYPT_MODE, key);
} catch (InvalidKeyException e) {
e.printStackTrace();
}
return true;