NovusMobile
NovusMobile

Reputation: 1833

Android M fingerprint Scanner Support example getting Nullpointer exception

Application : FingerPrint Scanner Support

Source : GIT HUB : Android FingerPrint Dialog

Issue : Nullpointer exception

File Name : MainAcitivty.java

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

Method :

   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);
        }
    }

Getting Nullpointer Exception in this method.

Is it due to keystore or Cipher initialization ?

Upvotes: 2

Views: 730

Answers (1)

Graydyn Young
Graydyn Young

Reputation: 5081

Maybe the @Inject annotation has failed you so your mKeyStore is still null? You could try pulling the initialization out of the FingerprintModule and into the onCreate of MainActivity.

Upvotes: 1

Related Questions