Kotlin Help

Migrate from kapt to KSP

This guide explains how to migrate your annotation processors from Kotlin Annotation Processing Tool (kapt) to Kotlin Symbol Processing (KSP). Your project can take full advantage of Kotlin features and improve build performance.

kapt lets you use Java annotation processors in Kotlin. It translates Kotlin source code into Java "stubs" and then runs the annotation processors on those stubs. However, this process is expensive, significantly increases build time, and loses some Kotlin-specific features in translation.

In contrast, KSP is an alternative to kapt designed specifically for Kotlin. KSP reduces build time by analyzing Kotlin source directly and exposing Kotlin-specific information like nullability.

Before you start

Check whether the processors in your project support KSP. See the list of supported libraries or consult their documentation.

Add the KSP plugin to your project

Add the KSP plugin to the plugins {} block in the project-level build.gradle(.kts) file:

// build.gradle.kts plugins { id("com.google.devtools.ksp") version "2.3.12" apply false }
// build.gradle plugins { id 'com.google.devtools.ksp' version '2.3.12' apply false }

Replace kapt with KSP in your modules

Find the module that uses the processor you want to migrate. In the module's build.gradle(.kts) file:

  1. Add the KSP plugin to the plugins {} block:

    // build.gradle.kts plugins { id("com.google.devtools.ksp") }
    // build.gradle plugins { id 'com.google.devtools.ksp' }
  2. In the dependencies {} block, replace kapt with ksp:

    // build.gradle.kts dependencies { implementation("com.google.dagger:dagger:2.48") // Replaces kapt("com.google.dagger:dagger-compiler:2.48") ksp("com.google.dagger:dagger-compiler:2.48") }
    // build.gradle dependencies { implementation 'com.google.dagger:dagger:2.48' // Replaces kapt 'com.google.dagger:dagger-compiler:2.48' ksp 'com.google.dagger:dagger-compiler:2.48' }

For most libraries, this replacement is enough. Check each library's documentation to see if you need to make any additional changes.

Remove the kapt plugin

After migrating all your processors to KSP, you can safely remove the kapt plugin from all build.gradle(.kts) files:

// build.gradle.kts plugins { // Remove the kapt plugin declaration: id("org.jetbrains.kotlin.kapt") }
// build.gradle plugins { // Remove the kapt plugin declaration: id 'org.jetbrains.kotlin.kapt' }

Delete any leftover kapt configuration, such as the kapt {} block, if you have it.

See also

17 November 2026