-->

Jacoco 0.8.2 and Android Gradle plugin 3.2.0 test

2019-08-16 23:35发布

问题:

I just tracked down an issue I'm having with partial coverage reports due to Android Gradle plugin 3.2.0

Jacoco is only generating coverage reports for less than 10% of my project. If I revert back to 3.1.4, it behaves as expected.

Is there any known issue with AGP 3.2.+ and JaCoCo test coverage?

回答1:

In absence of Minimal, Complete, and Verifiable example that demonstrates steps to reproduce your difficulty, one can only guess.

Simple search in bugtracker of Android Gradle Plugin by word "JaCoCo" reveals for example

  • https://issuetracker.google.com/issues/112324134
  • https://issuetracker.google.com/issues/117956165
  • https://issuetracker.google.com/issues/111569276
  • https://issuetracker.google.com/issues/120438249

with the same root cause

Location of class files has changed in newer versions of AGP. You need to change

def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)

to

def debugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug", excludes: fileFilter)

P.S. side-by-side comparison of old report with a new one can also give hints