Android JAVA Byte Code missing after update Gradle and Build Tools

最后都变了- 提交于 2019-12-13 16:08:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!