Jacoco code coverage was working fine till I upgrade Android Gradle Plugin to 4.2.0 , no only app module code coverage getting generated, for modules it is not working. Any Idea how to fix this issue.
I was having the same problem after upgrading to 4.2.1.
It looks like the Jacoco execution data file for non-instrumented unit tests has been renamed to 'jacoco.exec', and moved to the module's top-level directory.
In the configuration of my JacocoReport gradle task, this works for me:
executionData.from = "${project.projectDir}/jacoco.exec"
NOTE: The execution data file for instrumented tests has not been renamed or moved.
Based on amazing Richard answer, if you previously had this setup (which is pretty standard for unit and instrumented tests with Jacoco in Android)
executionData.from = fileTree(dir: project.buildDir, includes: [
"jacoco/${testTaskName}.exec",
"outputs/code_coverage/${variantName}AndroidTest/connected/**/*.ec"
])
You can switch to this equivalent for AGP 4.2.X
executionData.from = files([
"$project.projectDir/jacoco.exec",
fileTree(dir: project.buildDir, includes: [
"outputs/code_coverage/${variantName}AndroidTest/connected/**/*.ec"
])
])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With