Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.VerifyError when running Android tests with testCoverageEnabled = true

I've recently tried the new Jacoco code coverage feature for Android Gradle plugin, and unfortunately it makes my tests fail with the following error:

 java.lang.VerifyError: com/foo/bar/rest/SomeClass at
 com.foo.bar.test.rest.BaseTest.setUp(BaseTest.java:87) at
 android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190) at
 android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175) at
 android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
 at
 android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)

I enabled the code coverage using these lines in build.gradle:

 buildTypes {

         debug {
             testCoverageEnabled = true
         } 
...

Has anyone encountered the same problem?

like image 875
Egor Avatar asked Sep 09 '25 23:09

Egor


2 Answers

Turning @ben75's comment into an answer: The corresponding bug has been fixed with build-tools 21.0.0. However, that version introduced another Windows-specific bug, so you should use build-tools 21.0.2 instead (even though that version does not yet show up on the revisions page).

like image 50
sschuberth Avatar answered Sep 12 '25 12:09

sschuberth


I was running into this same problem, but found this solution: add -noverify to your gradle file like so:

testOptions {
    unitTests {
        all {
            // configure the test JVM arguments
            jvmArgs '-noverify'
        }
    }
}

Source: https://github.com/robolectric/robolectric-gradle-plugin/issues/144

like image 23
dstrube Avatar answered Sep 12 '25 14:09

dstrube