Android 指纹认证:加密原语未初始化

Android Fingerprint Authentication: Crypto primitive not initialized

我在一周前运行良好的应用程序中实现了指纹验证。代码没有更改,我现在收到以下错误:

FATAL EXCEPTION: main
    Caused by: java.lang.IllegalStateException: Crypto primitive not initialized

我不确定发生了什么,因为代码中没有任何更改,甚至通过干净地拉动分支进行验证。

下面是我在应用程序中使用的依赖项列表。

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.1'
compile 'com.android.support:design:23.+'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.squareup.okhttp:okhttp:2.7.1'
compile 'org.jdeferred:jdeferred-android-aar:1.2.4'
compile 'com.google.code.gson:gson:1.7.2'
compile "com.mixpanel.android:mixpanel-android:4.6.4"
compile "com.google.android.gms:play-services:3.1+"
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
    transitive = true;
}
compile 'io.branch.sdk.android:library:1.+'
compile 'com.parse.bolts:bolts-applinks:1.4.0'
compile 'com.github.greenfrvr:rubber-loader:1.1.2@aar'
compile 'com.github.deano2390:MaterialShowcaseView:1.0.6@aar'

关于这些新的 API,有什么我应该注意的吗?

您需要为加密或解密初始化密码对象

cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7);

cipher.init(Cipher.ENCRYPT_MODE, key);

根据您要执行的操作,您可能还需要生成 SecretKey、KeyStore 和 KeyGenerator。如果需要,我可以进一步详细说明。