Android M指纹扫描仪支持示例获取Nullpointer异常

时间:2015-07-23 06:28:53

标签: android nullpointerexception keystore secret-key

应用程序:FingerPrint扫描仪支持

资料来源:GIT HUB:Android FingerPrint Dialog

问题:Nullpointer异常

文件名: MainAcitivty.java

路径:https://github.com/googlesamples/android-FingerprintDialog/blob/master/Application/src/main/java/com/example/android/fingerprintdialog/MainActivity.java

方法:

   private boolean initCipher() {
        try {
            mKeyStore.load(null);
            SecretKey key = (SecretKey) mKeyStore.getKey(KEY_NAME, null);  
            mCipher.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);
        }
    }

在此方法中获取Nullpointer Exception

归因于keystoreCipher初始化吗?

1 个答案:

答案 0 :(得分:1)

也许@Inject注释失败了你所以你的mKeyStore仍然是空的?您可以尝试从FingerprintModule中拉出初始化并进入MainActivity的onCreate。