I was having a bit of trouble getting this combination of tools working, and found most of the information available to be missing or incomplete, but managed to cobble together something that works, so hopefully this helps someone else (or me later when I try it again):
<center> ![file](/uploads/image-1599624645827.png) <br/> Typical Jacoco report for a hello-kotlin-android app. </center>
In this guide, I found using the [jacoco-android plugin](https://proandroiddev.com/cloud-continuous-integration-on-android-with-kotlin-project-8d6f12cbf0c4) a helpful way to avoid having to [add a whole bunch of groovy](http://vgaidarji.me/blog/2017/12/20/how-to-configure-jacoco-for-kotlin-and-java-project/) to get Jacoco to find the Kotlin classes. Unfortunately, the recommended version of the plugin (0.1.2) came up with a [missing property error](https://stackoverflow.com/questions/53789337/gradle-sync-failed-missingpropertyexception-after-upgrade-to-gradle-5-1). The solution is to bump the version to at least `0.1.4.`
This goes in the project build.gradle:
Then in the app build.gradlethe jacoco-android plugin should be applied. I added this right after the kotlin-android plugin is applied.
apply plugin: 'jacoco-android'
This still will not cause the reports to be generated correctly, however, so I found from a [non-android kotlin tutorial](https://hleb-albau.com/kotlin-jacoco-coverall-integration) that adding the following to the android configuration block in the app will work:
append = false
destinationFile = file("$buildDir/jacoco/moduleTestsCoverage.exec")
includeNoLocationClasses = true
excludes = ['jdk.internal.*']
After this you should see the reports showing up in app/build/reports/jacoco.
If you want to start from a working repository, you can check out a [demo project I created on Github](https://github.com/compscidr/hello-kotlin-android).
[Originally posted on medium on December 2, 2019](https://medium.com/@compscidr/kotlin-android-junit5-jacoco-gradle-5-4-1-59c3eaf3b666).