- Add plugins.gradle repository
In the project build.gradle file (root/build.gradle) add url "https://plugins.gradle.org/m2/"
under the buildscript > repositories sections. In my project is looks like this:
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
- Apply jacoco plugin
The plugin can be applied in the project build.gradle or (as in my case) to the specific module's build.gradle (module/build.gradle):
apply plugin: 'com.vanniktech.android.junit.jacoco'
Apply the plugin at the very top of the build script before you enter the android
section.
- Sync Now when prompted.
- Run gradlew connectedCheck
From the Terminal run:
Windows
gradlew.bat connectedCheck
Linux (other)
./gradlew connectedCheck
- The results will be created in /module/build/reports/androidTests/connected/index.html
References:
https://plugins.gradle.org/plugin/com.vanniktech.android.junit.jacoco
https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/