Skip to content
Latchkey

Kotlin kapt "cannot find symbol" for generated code in CI

kapt compiles generated Java stubs and a referenced generated symbol does not exist. Either generation failed earlier or the reference name is wrong.

What this error means

The build fails in a kapt task with error: cannot find symbol naming a generated class like DaggerAppComponent. It is deterministic.

gradle
> Task :app:kaptDebugKotlin FAILED
error: cannot find symbol
  DaggerAppComponent.create().inject(this)
  symbol:   class DaggerAppComponent

Common causes

Generation failed upstream

An earlier processor error means the generated class was never produced, so the reference cannot resolve.

Processor not declared with kapt

The annotation library is present but the matching processor was not added via kapt(...), so nothing generates.

Stale generated sources cached

A cached build keeps generated output from before a rename, so the new name is missing.

How to fix it

Declare the processor with kapt

build.gradle.kts
dependencies {
  implementation("com.google.dagger:dagger:2.51")
  kapt("com.google.dagger:dagger-compiler:2.51")
}

Resolve the real generation error first

  1. Scroll above the cannot-find-symbol line to the actual processor error.
  2. Fix that error so the class generates.
  3. Run a clean build to drop stale generated sources.
CI step
./gradlew clean :app:kaptDebugKotlin

How to prevent it

  • Declare every processor with kapt or ksp.
  • Fix upstream processor errors before chasing missing symbols.
  • Clean generated sources after renames.

Related guides

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