在执行“gradle createDebugCoverageReport”期间出现以下问题:
出了什么问题:无法确定任务“:createDebugAndroidTestCoverageReport”的依赖关系。java.lang.NullPointerException(没有错误信息)
尝试:使用 --info 或 --debug 选项运行以获得更多日志输出。
例外是:
org.gradle.api.GradleException: Could not determine the dependencies of task ':createDebugAndroidTestCoverageReport'.
at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.resolve(CachingTaskDependencyResolveContext.java:67)
at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:55)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.addToTaskGraph(DefaultTaskExecutionPlan.java:139)
...
Caused by: java.lang.NullPointerException
at com.android.build.gradle.internal.variant.BaseVariantData.getJavaSourceFoldersForCoverage(BaseVariantData.java:682)
at com.android.build.gradle.internal.coverage.JacocoReportTask$ConfigAction.lambda$execute$3(JacocoReportTask.java:335)
at org.gradle.util.GUtil.uncheckedCall(GUtil.java:401)
我已经尝试了所有提示:如何使用 Android gradle 插件 0.10.0 或更高版本获取 jacoco 覆盖率报告?. 唯一的区别是我使用的是 0.8.3 版的实验性 gradle 插件。
buildscript {
repositories {
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.8.3'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.model.application'
apply plugin: "jacoco"
model {
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId ...
minSdkVersion.apiLevel 21
targetSdkVersion.apiLevel 25
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
...
debug {
debuggable true
testCoverageEnabled true
}
}
testOptions.unitTests {
returnDefaultValues = true
}
}
android.sources {
...
test {
java {
source {
srcDir "UnitTests"
}
}
}
androidTest {
java {
source {
srcDir "AutomationTests"
}
}
}
}
}
dependencies {
...
}
任何想法?谢谢。