Rejecting class because it failed compile-time verification Android
Asked Answered
H

5

9

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

Hartzell answered 26/5, 2015 at 9:52 Comment(1)
Possible related Issue on AOSP Issue tracker: code.google.com/p/android/issues/…Titanate
H
9

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) {
    }
}
Hartzell answered 26/5, 2015 at 9:52 Comment(0)
N
4

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.....

Naldo answered 11/5, 2016 at 10:18 Comment(0)
U
2

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
    }
}
Usufruct answered 9/9, 2016 at 10:12 Comment(1)
This would break lambdas though.Existential
O
1

This error also might happen due to usage of Mockito within an Android InstrumentationTest. If the error appears on mocking objects then you have to add this lines to you gradle-file:

androidTestCompile "com.crittercism.dexmaker:dexmaker:1.4"
androidTestCompile "com.crittercism.dexmaker:dexmaker-dx:1.4"
androidTestCompile "com.crittercism.dexmaker:dexmaker-mockito:1.4"

This works for me with Mockito 1.10.15 and 1.10.19.

Ovariotomy answered 4/11, 2016 at 19:3 Comment(0)
T
0

i had this problem to with android 5. my app did correctly on 4 or below but on android 5 devices i had crash.

i broke my codes with multiple Threads and it fixed. if your code wants to change the UI use handler .

 Thread Thread = new Thread(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            handler.post(new Runnable() {

                @Override
                public void run() {
                    use this if your codes will change the Ui

. . . . .

Timbale answered 3/10, 2015 at 4:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.