gpt4 book ai didi

Android Gradle 插件 3.1.0 不再找到 androidJacocoAnt 配置

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:59:22 26 4
gpt4 key购买 nike

更新到 Android Gradle 插件 3.1.0(从 3.0.1 开始)后,我的 JaCoCo 单元测试覆盖率配置开始在 Gradle 配置阶段产生错误:

> Configuration with name 'androidJacocoAnt' not found.

项目级build.gradle:

dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jacoco:org.jacoco.core:0.8.1"
}

模块级build.gradle:

apply plugin: 'jacoco'

...

android {
buildTypes {
debug {
testCoverageEnabled true
}
}

...
}

task jacocoTestReport(type: JacocoReport) {
dependsOn 'createDebugCoverageReport'
dependsOn 'testDebugUnitTest'

reports {
xml.enabled = true
html.enabled = true
csv.enabled = false
}

jacocoClasspath = configurations['androidJacocoAnt']

def fileFilter = [
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*'
]

def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
print("${project.projectDir}/src/main/java")

sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: "$buildDir", includes: [
"jacoco/testDebugUnitTest.exec",
"outputs/code-coverage/connected/*coverage.ec"
])
}

最佳答案

用不同的插件版本比较gradle dependencies的输出,似乎

jacocoClasspath = configurations['androidJacocoAnt']

需要改成

jacocoClasspath = configurations['jacocoAnt']

关于Android Gradle 插件 3.1.0 不再找到 androidJacocoAnt 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49509789/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com