问题
I'm using Jacoco to create a coverage report and that was working fine until update Gradle and BuildTools version. Then I revert those changes and work again.
Jacoco looks for .class files in here:
${buildDir}/intermediates/classes/debug
This is app/build/intermediates/classes/debug. But I've notice that after the upgrade that path is missing, there's no classes dir inside intermediates
My configuration which is working:
Project Level Module
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'io.fabric.tools:gradle:1.25.1'
App Level Module
compileSdkVersion 27
buildToolsVersion "27.0.3"
And when updated is this one:
Project Level Module
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'io.fabric.tools:gradle:1.25.4'
App Level Module
compileSdkVersion 28
buildToolsVersion "28.0.3"
I could not find any reference about that path being moved or what could be going on
EDIT
My problem is that as the Java Byte Code (generated .class files) does not exists, then Jacoco can not create a coverage report
回答1:
They are under intermediates\javac\debug\compileDebugJavaWithJavac\classes
You can configure Jacoco to change the classes path.
I'm not familiar with Jacoco but I think it has a property named includes
which is used for .class files.
Or there should be a .properties
for it I guess.
回答2:
one can change the classDirectories
used by the coverage task alike:
task "${testTaskName}Coverage" (type:JacocoReport, dependsOn: "$testTaskName") {
...
classDirectories = fileTree(
dir: "${project.buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes/${sourcePath}",
excludes: [ ... ]
)
...
}
来源:https://stackoverflow.com/questions/53374692/android-java-byte-code-missing-after-update-gradle-and-build-tools