首页 > 解决方案 > API<20 的 java.lang.VerifyError

问题描述

我制作了一个支持指纹安全的应用程序。只要我在大于 API 19 的 API 上运行它,一切正常。当然,自 Marshmallow 以来,指纹仅在设备中受支持,所以我用
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES. M) {}
我收到以下错误:

 java.lang.VerifyError: com/myapp/newapp/Introduction
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1208)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
    at        android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    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:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    at dalvik.system.NativeStart.main(Native Method)

我附上它,是由这部分代码引起的:

try {                                                               
            keyStore.load(null);
            SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME,
                    null);
            cipher.init(Cipher.ENCRYPT_MODE, key);
            //Return true if the cipher has been initialized successfully//
            return true;
        } catch (KeyPermanentlyInvalidatedException e) {

            //Return false if cipher initialization failed//
            return false;
        } catch (KeyStoreException | CertificateException
                | UnrecoverableKeyException | IOException
                | NoSuchAlgorithmException | InvalidKeyException e) {
            throw new RuntimeException("Failed to init Cipher", e);
        }                                                                  

我不知道如何解决它。

标签: javaandroidverifyerror

解决方案


推荐阅读