Skip to content
Latchkey

Kotlin "e: Unresolved reference" compile failure in CI

The Kotlin compiler prints diagnostics prefixed with e: for errors. "Unresolved reference" means the symbol has no definition on the compile classpath for that task - a dependency was never resolved, a generated file was not produced, or an import points nowhere on the CI runner.

What this error means

The compileKotlin (or compileDebugKotlin) task fails with one or more lines like "e: /path/File.kt: (12, 20): Unresolved reference: parseJson" and the build stops before tests run.

Kotlin
> Task :app:compileKotlin FAILED
e: /home/runner/work/app/app/src/main/kotlin/Http.kt: (7, 8): Unresolved reference: retrofit2
e: /home/runner/work/app/app/src/main/kotlin/Http.kt: (14, 21): Unresolved reference: create

Common causes

A dependency is not on the compile classpath

The import compiles locally because the artifact is cached, but the CI build resolved a different configuration (or the dependency was in testImplementation only), so the symbol is unresolved.

Generated source was not produced before compile

kapt, ksp, or a code generator did not run (or ran into the wrong sourceSet), so the referenced generated class does not exist when compileKotlin runs on the runner.

How to fix it

Declare the dependency in the right configuration

  1. Read which reference is unresolved and which module it belongs to.
  2. Add it to implementation (or api) in the module that imports it, not just testImplementation.
  3. Run ./gradlew :app:dependencies --configuration compileClasspath to confirm it appears.
build.gradle.kts
dependencies {
    implementation("com.squareup.retrofit2:retrofit:2.11.0")
}

Ensure generators run before compile

If the symbol is generated, make sure the ksp/kapt processor is applied and its output directory is wired into the Kotlin sourceSet so compileKotlin sees it.

Terminal
./gradlew clean :app:compileKotlin --info

How to prevent it

  • Run a clean build locally (delete build/ and the daemon cache) before pushing so classpath gaps surface.
  • Keep generated-source generators (ksp/kapt) wired into the same sourceSet that compiles.
  • Do not rely on transitively leaked dependencies; declare what you import.

Frequently asked questions

What causes ""e: ... Unresolved reference""?
The import compiles locally because the artifact is cached, but the CI build resolved a different configuration (or the dependency was in testImplementation only), so the symbol is unresolved.
How do I fix "e: ... Unresolved reference"?
Declare the dependency in the right configuration

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card