Android JaCoCo integration for Sonarqube

Dear Experts,

We’re trying to generate a Jacoco test report for our Android project to see the coverage results in Sonarqube. When I try to sync our code, we will receive the following error. We need an XML report for new version of Sonarqube, instead of exec file.

Our gradle version is 6.2.2, JaCoCo version is 0.8.6. Why are we receiving this error and how can we fix it?

Could not find method jacocoTestReport() for arguments [jacoco_1wfi6bvxampfsufxvx6i8m2kv$_run_closure2@35f46348] on project ‘:app’ of type org.gradle.api.Project.

Our module build.gradle file contains the following items:

apply plugin: 'jacoco'

jacocoTestReport {
    group = "Reporting"
    reports {
        xml.enabled true
        xml.destination "${buildDir}/reports/coverage"
        html.enabled true 


If I remember correctly, destination needs to be a File, not a String.

Hi Björn,

Eventhough I replace destination with a File like xml.destination file("${buildDir}/jacoco/jacocoTestReport.xml") , I got the same error.

“Could not find method jacocoTestReport() for arguments [jacoco_1wfi6bvxampfsufxvx6i8m2kv$_run_closure3@7fc32723] on project ‘:app’ of type org.gradle.api.Project.”

I think I only have seen such messages with the Groovy DSL when something in the closure is not good like using string where file is expected.

That’s one of the reasons I only use the Kotlin DSL these days, there you don’t have such problems or at least get a proper compile error.

I’d recommend you comment out all content of the closure, then it should hopefully work, then comment in line for line to see when it breaks.