Android Gradle Project jacoco report not found by sonar

Hi all,

I’m hoping someone can help me please.

I have managed to combine multi module coverage into a JacocoReport thanks to the help of this blog post. However, I am having problems with the sonar integration.

Here is my sonar.gradle:

apply plugin: "org.sonarqube"

sonarqube {
    properties {
        property "sonar.projectKey", "*******"
        property "sonar.organization", "*********"
        property "", ""
        property "sonar.token", "*********"
        property "", "jacoco"
        property "sonar.projectName", "*********"
        property "sonar.sources", ["src/test", "src/main/java"]
        property "sonar.tests", "src/test"
        property "sonar.test.inclusions", "**/*Test*/**"
        property "sonar.sourceEncoding", "UTF-8"
        property "sonar.sources", "src/main/java"
        property "", "jacoco"
        property "sonar.coverage.jacoco.xmlReportPaths", "/Users/james/Documents/Development/testapp/app/build/reports/jacoco/allDebugCoverage/allDebugCoverage.xml'."

When I run ./gradlew sonar -info

I can see:
No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths='build/reports/jacoco/allDebugCoverage/allDebugCoverage.xml'.

However, we can see from the image below, that the xml report is at that location.

Steps run here are manual currently with jacoco tasks run first then sonar afterwards. A

There may be something obvious that I am doing wrong, however, I cannot see what. So I would greatly appreciate any and all help is greatly.

Thank you

Hey there

It looks like you have some extra characters here, specifically '. at the end of your file path. Can you try removing that? It’s being interpreted literally by the scanner.

Hi Colin,

Thank you very much for coming back to me.

My apologies, that was a copy and paste error into my original post. Here is how I am setting the path manually property "sonar.coverage.jacoco.xmlReportPaths","build/reports/jacoco/allDebugCoverage/allDebugCoverage.xml"

This is set in my sonar.gradle file. Which I have added below. If there is any other information I can provide, can you please let me know. Thank you again for coming back to me.

sonarqube {
    properties {
        property "sonar.projectKey", "mo-android"
        property "sonar.organization", "***************"
        property "", ""
        property "sonar.token", "***********************"
        property "sonar.projectName", "**************"
        property "sonar.sources", "src/main/java"
        property "sonar.exclusions", ['***]
        property "", "jacoco"
        property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/allDebugCoverage/allDebugCoverage.xml"

It seems like the copy paste error somehow made its way into the logs, then? :confused:

Are your logs up-to-date with the configuration you just shared?

Hi Colin,
The logs state:

No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths='build/reports/jacoco/allDebugCoverage/allDebugCoverage.xml'. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml

I had copied the first line of the log and in error included the full stop. So the copy and paste error was me copying from the logs and including . in error.

This log is indeed aligned and up to date with the path initialised in the sonar config I’ve shared

@Colin Any help or guidance on this would be greatly appreciated.

Please don’t bump threads after less than a day!.

I’m starting to wonder if the report might be getting read in by the global coverage sensor but at the module level, it can’t find a per-file module (which makes sense if it’s a merged file).

Putting the error message aside, do you actually see any coverage data on SonarCloud?


Thank you for coming back to me. I don’t see any test coverage data on SonarCloud. I do see the code analysis as expected.

Apologies for bumping the thread :grimacing: this is my first time posting

I have also removed the implicit declaration of the path as suggested in a different post in this community to see would sonar pickup the report automatically but that hasn’t worked either unfortunately.

I removed all exclusions from sonar.exclusions in case some configuration was omitting the xml file but that hasn’t given any success either. I would really appreciate some guidance on this.

I imagine it is something small and trivial causing this issue but I cannot resolve it.

I’m a bit lost as well.

With [JACOCO-15] - Jira it’s possible to use wild-cards when specifying the JaCoCo report. Can you give that a try? Meaning a setting like:


Thank you Colin for coming back to me. I’ve tried that and I get the same issue

No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths='**/jacoco/allDebugCoverage/allDebugCoverage.xml'. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
No report imported, no coverage information will be imported by JaCoCo XML Report Importer

I’ve compared the jacoco html report to the xml and they match up i.e. branches covered/missed, lines covered/missed etc so I know the xml is valid format

We can see the path here in the screen shot…

Let me do what I should have done in the first place and clone the playground from the blog post you linked (and install the Android SDK :skull:). I’ll come back on this thread if I can (or can’t) reproduce it.

Super, thank you so much for your help Colin!

That was astoundingly painful for somebody who isn’t an expert in Kotlin, Gradle, or the Android SDK :laughing:

And, I was able to get coverage imported like this:

property "sonar.coverage.jacoco.xmlReportPaths", "${rootProject.buildDir}/reports/jacoco/allDebugCoverage/allDebugCoverage.xml"
1 Like

Great news!! This works for me! Did you notice, Is the coverage imported equal to the html file output? So for example, the html file reads 28% coverage, however, the coverage imported to sonarcloud is only 16.8%

For line coverage, which is what SonarCloud is tracking – yes, everything matches.

1 Like

Hi Colin,

Thank you for that. I may be veering off topic here but looking at my coverage on sonarcloud, it doesn’t recognise the separate module covered in the coverage. It’s not listed when I dig into the coverage on sonar cloud. It is listed under the xml, can you advise it if should be noted in sonar cloud?

There are three packages from the module that are included in the xml report file but aren’t listed in the coverage

If you can provide a reproducer (similar to the playground used before), I think that will help us figure out if it should be noted or not. I don’t quite understand the problem from your description.

Sonar cloud is not displaying three packages from the module. In your dashboard go to measurescoverage and view as tree map.

You should be able to reproduce it in the playground app, there are different packages in that per module. After the xml coverage report import, can you see each package in your sonar dashboard?

In my xml coverage report, all packages are there, from the separate modules and main codebase but the module packages are not displaying in sonarcloud.

The SonarCloud project is public, as far as I can tell all the code is represented.