Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rejecting class because it failed compile-time verification Android

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

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)

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

like image 835
XGouchet Avatar asked May 26 '15 09:05

XGouchet


3 Answers

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) {
    }
}
like image 108
XGouchet Avatar answered Nov 11 '22 05:11

XGouchet


in android studio 2.1 ,the instant run will cause this problem,just run after close the instant run function.

File -> Preferences > Build Execution -> Deployment -> Instant Run

Disable the first checkbox: Enable Instant Run to hot swap.....

like image 4
NEXT Avatar answered Nov 11 '22 05:11

NEXT


If you are building with Jack, make sure it's turned off from build.gradle

defaultConfig {
    ...
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    jackOptions {
        enabled false
    }
}
like image 1
Yao Avatar answered Nov 11 '22 05:11

Yao