Android M fingerprint Scanner Support example getting Nullpointer 异常

Android M fingerprint Scanner Support example getting Nullpointer exception

应用程序:指纹扫描仪支持

来源:GIT 集线器:Android FingerPrint Dialog

问题:空指针异常

文件名: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

是因为keystore还是Cipher初始化?

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