I'm getting error while run task written in android app gradle to generate HTML report from Jacoco coverage file

When i try to run task to generate HTML test report using Jacoco coverage.ec file. it throws error as " Error while creating report".
I follow this documentation - Android Coverage Guide - appium

below are the error from logcat -

Task :app:jacocoTestReport FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:jacocoTestReport’.

Error while creating report

Anyone have any solution or anyone have working task code so I can try it in my project.

task code I added in gradle (using kotlin gradle) is as below-

tasks.register<JacocoReport>("jacocoTestReport") {

group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."

reports {
    xml.required = true
    html.required = true

val fileFilter = arrayOf(
val debugTree = fileTree("$buildDir/intermediates/classes/debug") {
val mainSrc = "${project.projectDir}/src/main/java"


doFirst {
    File("$buildDir/intermediates/classes/").walkTopDown().forEach { file ->
        if (file.name.contains("$$")) {
            file.renameTo(File(file.path.replace("$$", "$")))

Might get a better answer from jacoco google group: