拒绝类,因为它未通过编译时验证Android [英] Rejecting class because it failed compile-time verification Android

查看:165
本文介绍了拒绝类,因为它未通过编译时验证Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个应用程序在启动时突然失败,并显示以下错误消息:

One of my application suddenly fails on startup, with the following error message :

java.lang.VerifyError:拒绝类 com.sample.BufferManagerImpl,因为它失败了 编译时验证(声明 'com.sample.BufferManagerImpl'出现在 /data/app/com.sample.myapp-1/base.apk)

java.lang.VerifyError: Rejecting class com.sample.BufferManagerImpl because it failed compile-time verification (declaration of 'com.sample.BufferManagerImpl' appears in /data/app/com.sample.myapp-1/base.apk)

它只会在使用ART虚拟机的设备上失败,而不会在Dalvik上

It only fails on devices using the ART virtual machine, but not on Dalvik

推荐答案

问题是由于try-catch块中有一个synchronized块,例如:

The issue is due to having a synchronized block inside a try-catch block, for example :

try {
    synchronized (mLock) {
        updateState();
    }
} catch (IllegalStateException e) {
}

显然,这不是一个好习惯,但是只要我这样更改它,它就会起作用:

Apparently this is not a good practice, but as soon as I change it like this it works :

synchronized(mLock) {
    try {
        updateState();
    } catch (IllegalStateException e) {
    }
}

这篇关于拒绝类,因为它未通过编译时验证Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆