Android Jacoco Coverage Empty With Gradle
Solution 1:
Try to generate the debug coverage report using Nexus device
(5 or 5x), it will works perfectly. I was facing same issue with Samsung devices
(coverage.ec is empty) but after that I run it with Nexus 5x
and everything was working fine.
Solution 2:
There's a problem in the Android Gradle Plugin 0.14.0 that generates an empty coverage.ec file. It's known and was fixed in a branch but doesn't seem to have made it out to the public yet: https://code.google.com/p/android/issues/detail?id=78556
On the other hand, a lovely workaround template project for Android Studio can be found here using Jacoco and RoboElectric: https://github.com/nenick/android-gradle-template
So you can wait for Google to fix it or use someone else's build library repository, but Android Studio 1.0.0's gradle plugin is useless.
Solution 3:
Jacoco should be inside of the android
closure and the jacoco plugin declaration is not necessary:
apply plugin: 'com.android.application'
...
android {
buildTypes {
release {
}
debug {
testCoverageEnabled true
}
}
jacoco {
toolVersion = "0.7.1.201405082137"
}
}
Solution 4:
I use same gradle.build and just enter the command below to terminal. It gave me coverage report and test result as a html page.
$./gradlew createDebugCoverageReport
Another suggestion is ; enter terminal
$./gradlew --gui
it opens a gui window and you can find the correct command.
Solution 5:
I found a solution to same problem from Jacoco code coverage in Android Studio with flavors. It has example what to do in case coverage.ec is generated instead of testDebug.exec
.
I created the
jacocoTestReport
task.I executed
$./gradlew createDebugCoverageReport
which generates thecoverage.ec
file- After that I executed
$./gradlew jacocoTestReport
and that creates the HTML.
Post a Comment for "Android Jacoco Coverage Empty With Gradle"