Use jacoco in android library Module

(Zhangzhen) #1

I write some JUnit test for an Android Library Module, then I wanna use jacoco plugin to get code coverage, my build.gradle like below:

apply plugin ''
apply plugin 'jacoco'
buildTypes {
        debug {
            testCoverageEnabled true

tast coverageReport(type: 'JacocoReport'){
  executionData = files('build/jacoco/testDebugUnitTest.exec')
    sourceDirectories = files('src/main/java')
    classDirectories = fileTree(dir: 'build/intermediates/classes/debug',
            excludes: ['**/R.class',
    reports {
        xml.enabled = true
        html.enabled = true

then I run the test task and coverageReport task:

gradle clean test
gradle coverageReport

At last, I got a Exception:

Incremental java compilation is an incubating feature.
:myLibrary:coverageReport FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':myLibrary:coverageReport'.
> org/jacoco/core/analysis/ICoverageNode

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.


My gradle version is 2.1.0, android gradle plugin version is 2.10.0, jacoco agent version is
What’s wrong with my config?Anyone can help me, thx