Android Studio 3.1 Canary 8 Build #AI-173.4529993,built on January 6,2018 JRE: 1.8.0_152-release-1024-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.14.14-300.fc27.x86_64
我正在尝试使用jacoco来生成代码覆盖率.但是,当我运行命令./gradlew任务时,我没有看到任何名为jacocoTestReport的任务.
当我尝试运行任务时出现以下错误./gradlew jacocoTestReport:
Task ‘jacocoTestReport’ not found in root project ‘EnumSample’
这是我的build.gradlew文件:
apply plugin: 'com.android.application' apply plugin: 'jacoco' android { compileSdkVersion 27 defaultConfig { applicationId "me.androidBox.enumsample" minSdkVersion 19 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro' } debug { testCoverageEnabled true } } } jacoco { toolVersion "0.8.0" } task jacocoTestReport(type: JacocoReport) { executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") subprojects.each { sourceSets it.sourceSets.main } reports { xml.enabled true html.enabled false csv.enabled false } } dependencies { implementation fileTree(dir: 'libs',include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.0.2' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' }
我试图清理并重建项目.但是,报告任务不存在.
非常感谢任何建议.