Skip to content
Latchkey

Kotlin "Unresolved reference: X" in CI

The Kotlin compiler found an identifier it cannot resolve to any declaration in scope. "e: Unresolved reference: X" marks the name and its location; the import or dependency that defines it is missing.

What this error means

Gradle compileKotlin fails with "e: /path/File.kt:(line): Unresolved reference: X" and "Compilation error" in the task summary.

kotlin
e: /app/src/main/kotlin/Main.kt: (5, 14): Unresolved reference: runBlocking
> Task :compileKotlin FAILED

Common causes

A missing import for the symbol

The function, class, or property is declared elsewhere and the file never imports it, so the name is unbound.

The providing dependency is not declared

The symbol lives in a library not on the compile classpath, so no import can resolve to it.

How to fix it

Add the missing import

  1. Read the line and column in the e: message.
  2. Import the symbol from its package.
  3. Re-run the Gradle build to confirm it resolves.
Main.kt
import kotlinx.coroutines.runBlocking

Declare the dependency that provides it

When the symbol comes from a library, add it so the import target is on the classpath.

build.gradle.kts
dependencies {
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
}

How to prevent it

  • Let the IDE manage imports rather than typing them by hand.
  • Declare every symbol-providing library in dependencies.
  • Build locally so unresolved references surface before CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →