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.
/app/build/tmp/kapt3/stubs/main/com/example/AppComponent.java:6: error: cannot find symbol
DaggerAppComponent.create();
^
symbol: class DaggerAppComponent
> Task :kaptDebugKotlin FAILEDCommon 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
- Scroll up to the first error before the "cannot find symbol" cascade.
- Fix that root processing error (a bad annotation, a missing binding).
- 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.
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
kaptconfiguration. - Consider migrating to KSP where the processor supports it.