Convert KAPT to KSP — Room and Hilt Examples

Step-by-Step Guide: Migrating from KAPT to KSP for Room Database and Hilt Dependency Injection

Vincent Tsen
2 min readJan 3, 2024

KAPT stands for Kotlin Annotation Processing Tool and KSP stands for Kotlin Symbol Processing. Both are annotation-processing tools that are used for code generation.

KAPT is the old way which is Java-based and KSP is the new way which is Kotlin-based, and it builds (generates codes) a lot faster than the KAPT.

The 2 most common Android libraries that use them are Room Database and Hilt Dependency Injection. Let’s explore the steps to convert these libraries from KAPT to KPT…

1. Update Kotlin version to minimum version “1.9.10”

In your project build.gradle file (Groovy example):

/*...*/
plugins {
/*...*/
id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
/*...*/
}
/*...*/

2. Add KSP Plugin to your build.gradle file

In your project build.gradle file (Groovy example):

/*...*/
plugins {
/*...*/
id 'com.google.devtools.ksp' version '1.9.10-1.0.13' apply false
/*...*/
}
/*...*/

--

--