Skip to content
Latchkey

Kotlin kapt/ksp annotation processing error

An annotation processor run by kapt or KSP failed. The generated code step errored out before Kotlin compilation could finish.

What this error means

The build fails in a kapt or ksp task with a processor error message - a missing dependency, an unsupported JDK, or a real annotation usage mistake. It is usually deterministic.

gradle
> Task :app:kaptGenerateStubsDebugKotlin FAILED
error: [ksp] ... symbol not found / processor crashed
java.lang.NoClassDefFoundError: javax/annotation/processing/Processor

Common causes

Processor dependency missing

The annotation library is on the classpath but the matching processor was not declared with kapt/ksp, so nothing generates.

JDK too new for kapt

kapt relies on internal compiler APIs that newer JDKs restrict, causing NoClassDefFound or illegal-access failures.

Invalid annotation usage

A real mistake in how an annotation is applied makes the processor report an error.

How to fix it

Declare the processor correctly

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

Migrate kapt to KSP where possible

  1. Adopt KSP for processors that support it; it is faster and JDK-friendlier.
  2. Apply the KSP Gradle plugin and switch kapt(...) to ksp(...).
  3. If staying on kapt, run on a JDK the processor supports.

Fix the flagged annotation

Read the processor message and correct the annotation usage it points to.

How to prevent it

  • Pin processor and JDK versions together.
  • Prefer KSP over kapt for new processors.
  • Run the annotation step locally before pushing.

Related guides

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