Ever since switching to use Jack to compile our Android application our Jacoco Code Coverage has stopped working. At first the problem was the "coverage always 0%" which I've seen mentioned by multiple others (Jacoco Test Coverage report shows 0%, android jacoco shows 0%...). However upon returning to try fixing it, I now find I can't even build the coverage tasks. After a lot of trying a number of random solutions offered across the internet I started a brand new Android Studio project and switched it to use Jack (no other changes) and it still fails with:
:main_project:createDebugAndroidTestCoverageReport FAILED
File '/path/to/project/build/intermediates/jack/striiv/debug/coverage.em' specified for property 'metadataFile' does not exist.
Here are my gradle files for the toy app.
project build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.tadams.app.jacoco"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions.enabled = true
jackOptions.jackInProcess = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled(true)
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
}
Thanks for any help you can give! In particular, I've been trying to research how the metadata file is supposed to be generated, but aside from the fact that Android is supposed to take care of it I'm having trouble understanding. Until then I'm just kind of guessing at solutions.
Edit: Remembered an important item in the Gradle logs:
:main_project:transformJackWithJackForDebugAndroidTest
Unable to find coverage plugin '/Users/tadams/Library/Android/sdk/build-tools/24.0.0/jack-coverage-plugin.jar'. Disabling code coverage.
The .jar is absolutely in that directory, so no idea why it wouldn't see it or how to fix it.