I inherited an android project to setup code coverage for. Not having done much for android and almost as little in gradle, I embarked on a quest to find a helpful tutorial. As
For anyone reading this... if you have the same issue, it is time to start banging your head against the wall...
Today I was lucky enough to stumble upon this: https://issuetracker.google.com/issues/37004446#comment12
The actual "problem" seems to be, that library projects are "always" of release type. Therefore they do not contain "necessary instrumentation setup" (unless you enable code coverage for release as well, although I haven't tested it).
So the solution is to specifically enable, in the library to be published, "debug" build (as mentioned, default is the release type):
android {
publishNonDefault true
}
Then, in the project that uses library, specify a debugCompile dependency (release compile can use the "default" release configuration):
dependencies {
debugCompile project(path: 'library', configuration: 'debug')
releaseCompile project('library')
}
And of course (this one I take for granted), remember to enable test coverage for the library:
android {
buildTypes {
debug {
testCoverageEnabled true
}
}
}