Kotlin kapt annotation processing failed in CI
kapt runs Java annotation processors against Kotlin by first generating Java stubs, then processing them. A failure in kaptGenerateStubsKotlin or kapt means a processor threw, a stub did not compile, or the processor dependency is declared with the wrong configuration (implementation instead of kapt).
What this error means
A :app:kaptKotlin or :app:kaptGenerateStubsKotlin task fails, sometimes with "error: [kapt] An exception occurred" or a processor-specific message, before compileKotlin finishes.
> Task :app:kaptDebugKotlin FAILED
error: [kapt] An exception occurred: java.lang.IllegalStateException: ...
e: error: cannot find symbol (generated Dagger component missing)Common causes
The processor is on the wrong configuration
An annotation processor added with implementation instead of kapt never runs, so generated types are missing and dependent code fails.
A processor error surfaced only in a clean CI build
Stale generated output masked a processor error locally; a clean CI build regenerates and the real failure appears.
How to fix it
Declare processors with the kapt configuration
- Apply the kapt plugin.
- Move each annotation processor to the
kapt(...)configuration. - Run a clean build so stubs and generated code are regenerated.
plugins { kotlin("kapt") }
dependencies {
implementation("com.google.dagger:dagger:2.51.1")
kapt("com.google.dagger:dagger-compiler:2.51.1")
}Read the processor error in a clean build
Run kapt with info logging on a clean tree to see the underlying processor exception.
./gradlew clean :app:kaptDebugKotlin --infoHow to prevent it
- Always declare annotation processors under the
kaptconfiguration. - Prefer migrating to ksp where the processor supports it (faster, fewer stubs).
- Run clean builds in CI so stale generated output never hides errors.