Android Gradle: Jacoco error

This tutorial fixes Jacoco 4.6 issues when updating to Gradle 4.0.1 and wrapper 6.6.1.

Cannot set the value of read-only property 'executionData' for task ':client:jacocoTestFlavorDebugUnitTestReport' of type org.gradle.testing.jacoco.tasks.JacocoReport.

In the last version something is broken between Jacoco’s gradle plugin and Gradle, thanks to this fork for the solution. With Jacoco and Gradle we generate a test code coverage report for our Android project, shows the percentage of unit tests coverage. If we configure Codecov we can add our unit test coverage badge to our GitHub repo

Fix Jacoco build error Inside build.gradle:

  1. Replace:
classpath ‘com.dicedmelon.gradle:jacoco-android:0.1.4’

with:

classpath 'com.hiya:jacoco-android:0.2'
maven { url “https://plugins.gradle.org/m2/" }

2. Replace:

apply plugin: 'jacoco-android'

with:

apply plugin: 'com.hiya.jacoco-android'

In case you have Gradle `error classDirectories` fix with below changes:

Replace:

classDirectories = fileTree(

with:

getClassDirectories().setFrom(fileTree(

Thanks for reading. I started to publish my daily notes. Let me know if I’m wrong somewhere or if there’s something that could do differently or better. I’m open to your feedback 🙌🏻

Andres

software engineer, read, swim, travel. apps: https://goo.gl/rDuuQw https://goo.gl/15GvfE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store