Hey there 👋
I work on an Android project that contains custom lint rules. The lint module contains the below dependencies block:
dependencies {
compileOnly("com.android.tools.lint:lint-api:lint-version")
compileOnly("com.android.tools.lint:lint-checks:lint-version")
testImplementation("com.android.tools.lint:lint-tests:lint-version")
testImplementation(libs.kotlin.test.junit)
}
It uses Gradle version catalogs, but it is probably obvious which dependencies it is referring to. I am in the process of migrating from Kotlin 1.8.21 to 1.9.10 and all of a sudden the custom lint tests started failing with errors like this:
Cannot access class 'com.android.tools.lint.detector.api.Issue'. Check your module classpath for missing or conflicting dependencies
Basically, unit tests cannot resolve dependencies that are configured with
compileOnly
. That used to work before migrating to Kotlin 1.9+. I found a way to fix the problem by adding the below configuration block:
configurations {
// Give tests visibility into dependencies configured as compileOnly
testImplementation.extendsFrom(compileOnly)
}
Does anyone know why Kotlin 1.9+ would cause this issue? Is my configurations block the correct way to solve it?
Thanks!