26

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?

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
Egor
  • 39,695
  • 10
  • 113
  • 130

3 Answers3

4

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

sschuberth
  • 28,386
  • 6
  • 101
  • 146
1

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

dstrube
  • 33
  • 5
-2

You'll receive a java.lang.VerifyError anytime there is inconsistency between the library used during compilation and run-time.

Here's another thread that lists similar issue : Java.lang.verifyerror how do I fix or even find out the root cause?

Community
  • 1
  • 1
Zeus
  • 432
  • 7
  • 19