Skip to content
Latchkey

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.

Kotlin
> 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

  1. Apply the kapt plugin.
  2. Move each annotation processor to the kapt(...) configuration.
  3. Run a clean build so stubs and generated code are regenerated.
build.gradle.kts
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.

Terminal
./gradlew clean :app:kaptDebugKotlin --info

How to prevent it

  • Always declare annotation processors under the kapt configuration.
  • Prefer migrating to ksp where the processor supports it (faster, fewer stubs).
  • Run clean builds in CI so stale generated output never hides errors.

Frequently asked questions

What causes ""kapt ... annotation processing" failed"?
An annotation processor added with implementation instead of kapt never runs, so generated types are missing and dependent code fails.
How do I fix "kapt ... annotation processing" failed?
Declare processors with the kapt configuration

Related guides

References

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