Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android JAVA Byte Code missing after update Gradle and Build Tools

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

like image 410
sebasira Avatar asked Nov 19 '18 12:11

sebasira


2 Answers

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.

like image 126
M D P Avatar answered Sep 22 '22 00:09

M D P


One can change the classDirectories used by the coverage task alike this:

task "${testTaskName}Coverage" (type:JacocoReport, dependsOn: "$testTaskName") {
    ...
    classDirectories = fileTree(
        dir: "${project.buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes/${sourcePath}",
        excludes: [ ... ]
    )
    ...
}
like image 44
Martin Zeitler Avatar answered Sep 19 '22 00:09

Martin Zeitler