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.
> 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: createCommon 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
- Read which reference is unresolved and which module it belongs to.
- Add it to
implementation(orapi) in the module that imports it, not justtestImplementation. - Run
./gradlew :app:dependencies --configuration compileClasspathto confirm it appears.
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.
./gradlew clean :app:compileKotlin --infoHow 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.