Skip to content
Latchkey

Kotlin kapt "error: cannot find symbol" in CI

kapt runs Java annotation processors against generated stubs, and a processor referenced a symbol that was never generated. The "cannot find symbol" comes from javac inside kapt, usually triggered by an earlier processing error.

What this error means

The kaptKotlin or kaptGenerateStubs task fails with "error: cannot find symbol" naming a generated class (a Dagger component, a generated binding) that does not exist.

kotlin
/app/build/tmp/kapt3/stubs/main/com/example/AppComponent.java:6: error: cannot find symbol
  DaggerAppComponent.create();
  ^
  symbol:   class DaggerAppComponent
> Task :kaptDebugKotlin FAILED

Common causes

An earlier processing error stopped generation

A real error elsewhere in annotation processing aborted code generation, so the referenced generated class was never produced.

The processor dependency is missing or wrong

The annotation processor is not declared with kapt(...), so no class is generated for the referenced symbol.

How to fix it

Find the first real kapt error

  1. Scroll up to the first error before the "cannot find symbol" cascade.
  2. Fix that root processing error (a bad annotation, a missing binding).
  3. Re-run so generation completes and the symbol appears.

Declare the processor with kapt

Add the annotation processor on the kapt configuration so it generates the expected classes.

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

How to prevent it

  • Read the first error, not the generated-symbol cascade.
  • Declare every processor on the kapt configuration.
  • Consider migrating to KSP where the processor supports it.

Frequently asked questions

What causes ""cannot find symbol" (kapt)"?
A real error elsewhere in annotation processing aborted code generation, so the referenced generated class was never produced.
How do I fix "cannot find symbol" (kapt)?
Find the first real kapt error

Related guides

References

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