2017-02-03 8 views
1

私のアプリケーションで指紋センサーを使用しています。 私はapiがマシュマロとそれ以上のOSで利用できることを知っています。私のクラスで走っている間、私はsdkバージョンを動的にチェックしています。Android VerifyError例外

フィンガープリントのコードでも実行されません。4.0以降のアンドロイドOSで例外が発生しましたが、5.0以上で実行されます。

**java.lang.VerifyError: com/cloudzon/gratzeez1/GiveGratuityActivity 
                     at java.lang.Class.newInstanceImpl(Native Method) 
                     at java.lang.Class.newInstance(Class.java:1215) 
                     at android.app.Instrumentation.newActivity(Instrumentation.java:1061) 
                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2265) 
                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 
                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342) 
                     at android.os.Handler.dispatchMessage(Handler.java:110) 
                     at android.os.Looper.loop(Looper.java:193) 
                     at android.app.ActivityThread.main(ActivityThread.java:5322) 
                     at java.lang.reflect.Method.invokeNative(Native Method) 
                     at java.lang.reflect.Method.invoke(Method.java:515) 
                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829) 
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) 
                     at dalvik.system.NativeStart.main(Native Method)** 

私のクラスの次のコードのために、私はこの問題に直面していることがわかりました。

public boolean cipherInit() { 
    try { 
     cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); 
    } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { 
     throw new RuntimeException("Failed to get 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); 
    } 
} 
+0

「bcz」とは何ですか? – Doomsknight

+0

今すぐチェックしてください –

+0

5.0でも同じコードが使えますか? –

答えて

2

私もこれに遭遇しました。もう1つの答えが正しい軌道に乗りました。 How to Use Unsupported Exception for Lower Platform Version

私はこのメソッドを次のように変更します。 (KeyPermanentlyInvalidatedException電子)からKeyPermanentlyInvalidatedExceptionためのcatchブロックを変更

public boolean cipherInit() { 
    try { 
     cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); 
    } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { 
     throw new RuntimeException("Failed to get Cipher", e); 
    } 

    try { 
     keyStore.load(null); 
     SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME, null); 
     cipher.init(Cipher.ENCRYPT_MODE, key); 
     return true; 
    } catch (Exception e) { 
     if(e instanceof KeyPermanentlyInvalidatedException) 
      return false; 
     else if(e instanceof KeyStoreException|e instanceof CertificateException|e instanceof UnrecoverableKeyException|e instanceof IOException|e instanceof NoSuchAlgorithmException|e instanceof InvalidKeyException) 
      throw new RuntimeException("Failed to init Cipher",e); 
    } 
    return false; 
} 

(KeyPermanentlyInvalidatedException instanceofはE)は、何らかの理由で問題を解決するように見えました。

+0

で正常に動作していますが、このエラーを初めて遭遇します。誰もここに答えがないようです。クラスの新しいインスタンスを作成するときにアプリケーションモジュールで取得する人 –

+0

エラーがAndroidプロジェクトにCipherやFingerprintコードを追加することに関連していない場合、私は新しい質問をすることをお勧めします。 – opt05

+0

私の同じ問題に取り組んでいます。どうもありがとう – Kalanidhi