- ⚠️ Gradle "plugin not found" errors are most often caused by an improperly declared KSP plugin or version mismatch with Kotlin.
- Using Kotlin Symbol Processing (KSP) instead of KAPT can cut build times in half for Room-based Android apps.
- 🏗️ Room version 2.4.0 and above includes native KSP support—no need for KAPT in Kotlin projects.
- Keeping Kotlin, Room, and KSP versions compatible is important to avoid Android Studio sync failures.
- 🔧 Gradle's Version Catalog and BOMs can greatly reduce version mismatch issues in multi-developer projects.
Running into Gradle sync errors when setting up your Room database with the Kotlin Symbol Processing (KSP) plugin? You're not alone. The “KSP plugin not found” message can stop your Android Studio build, and it takes up your coding time. This guide explains why this Android Studio error happens, how to fix it fast, and how to set up KSP with Room the right way from the start.
What Is the KSP Plugin and Why Use It with Room?
The Kotlin Symbol Processing (KSP) plugin is an annotation processing tool made just for Kotlin. Google developed and maintains KSP. It is a faster, more Kotlin-friendly option than the Java-based Kotlin Annotation Processing Tool (KAPT). Annotation processing is an important way libraries like Room, Dagger, and Moshi generate extra code when you compile your project.
Compared to KAPT, KSP:
- Processes Kotlin code natively without converting it to Java stubs.
- Makes incremental builds shorter because it runs better.
- It also helps avoid bugs from type erasure and nullability mismatches. This is because it works right on the Kotlin Abstract Syntax Tree (AST).
Room, Android’s Jetpack persistence library, now officially suggests using KSP in Kotlin projects. This is because it works better with Kotlin and processes things faster.
“KSP offers up to 2x speed improvement over KAPT in typical annotation processing workflows.” — JetBrains, 2022
Common Causes of “Gradle Cannot Find KSP Plugin” Error
One of the common Android Studio errors that developers see during build setup is:
Plugin [id: 'com.google.devtools.ksp'] was not found in any of the following sources...
This error typically appears during a Gradle sync and stops your project from compiling. It means your build system can't find the KSP plugin you listed.
Typical Triggers Include:
- KSP plugin is not declared in your module’s
build.gradle(.kts)file. - The plugin version does not match your Kotlin version.
- A plugin repository (like Google or Maven Central) is missing from
settings.gradle.kts. - Confusion between Groovy and Kotlin Gradle scripts.
- Mixing
kaptandkspdependencies for the same annotation processor.
Understanding why this plugin is failing is the first step to a working build system.
Missing or Incorrect Plugin Declaration: The Core Cause
Often, this error happens because the plugin is missing or declared wrong. Gradle finds plugins using plugin repositories. These include the Gradle Plugin Portal or Google's Maven repository. If you don't declare the plugin in the right spot, or if you use the wrong version, Gradle can't find or use it.
Correct Kotlin DSL Declaration
For projects using Kotlin DSL (build.gradle.kts), your module-level plugin block should include:
plugins {
id("com.android.application")
kotlin("android")
id("com.google.devtools.ksp") version "1.9.0-1.0.13"
}
Compatibility Matrix: Kotlin ↔ KSP
Each KSP release is linked to certain Kotlin versions. Using the wrong combination can cause errors where classes don't work together. This can happen even if the plugin is found.
| Kotlin Version | Compatible KSP Version |
|---|---|
| 1.9.0 | 1.9.0-1.0.13 |
| 1.8.21 | 1.8.21-1.0.11 |
| 1.7.10 | 1.7.10-1.0.6 |
| 1.6.10 | 1.6.10-1.0.2 |
“KSP releases are tied to Kotlin progression versions.” — Tencent, 2022
Always refer to the official KSP versioning guide before updating.
Full Setup: Integrating Room with KSP
A proper build setup ensures that Room works well with the KSP plugin. Let’s walk through the steps with a current best way to do things.
1. Apply the KSP Plugin
At the module level (build.gradle.kts):
plugins {
id("com.google.devtools.ksp") version "1.9.0-1.0.13"
}
Replace the version string to match your Kotlin version as explained earlier.
2. Declare Dependencies
Room’s compiler supports KSP natively from version 2.4.0 onwards.
dependencies {
implementation("androidx.room:room-runtime:2.5.2")
implementation("androidx.room:room-ktx:2.5.2")
ksp("androidx.room:room-compiler:2.5.2")
}
Do not make this common mistake:
Using kapt("androidx.room:room-compiler")—this is intended for Java/KAPT setups.
3. Project-Level Plugin Management
In settings.gradle.kts, ensure repositories are included:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
This block ensures that Gradle can locate the plugin during resolution.
4. Configure Android Parameters
Define your compilation targets in build.gradle.kts:
android {
compileSdk = 34
defaultConfig {
applicationId = "com.example.roomapp"
minSdk = 24
targetSdk = 34
}
}
Be sure your Gradle wrapper and Android Gradle Plugin (AGP) versions support this compile SDK.
Version Compatibility: Don’t Mix and Break
Kotlin, Room, and KSP must have matching versions. Even one mismatch can lead to build errors that are hard to understand:
| Component | Minimal Version |
|---|---|
| Room | 2.4.0 |
| KSP | Matching Kotlin version |
| Kotlin | 1.6.10 or higher |
“Room 2.4.0 introduced KSP compiler support, removing the need for KAPT in Kotlin-based apps.” — Android Developers, 2022
Still Seeing Errors? Clean and Rebuild
To recover from a broken build state, follow these steps:
-
Clean Your Project
Navigate toBuild→Clean Projectin Android Studio. -
Invalidate Caches / Restart
ClickFile→Invalidate Caches / Restart.... -
Sync Gradle Files
ChooseFile→Sync Project with Gradle Files. -
Delete
*.imlFiles
Manually removing.ideaand*.imlfiles can fix workspace issues that happen from VCS merges.
Version Catalog & Dependency Inspection
To make your dependencies more stable for the future and avoid duplication:
Inspect via CLI
./gradlew :app:dependencies
View resolved dependency versions across configurations. This is useful for finding conflicts that come through other dependencies.
Version Catalog Example
In gradle/libs.versions.toml:
[ksp]
version = "1.9.0-1.0.13"
In build.gradle.kts:
id("com.google.devtools.ksp") version libs.versions.ksp.get()
This setup makes sure there is one clear place for dependency versions across modules and environments.
Avoiding Common Pitfalls
Mixing kapt and ksp in the same module: Use only one.
Forgetting the pluginManagement block in the root settings.gradle.kts file.
Kotlin and KSP versions do not match: Always check these before syncing.
Incorrect dependency scope: Use ksp(...) for KSP compiler processors. Do not use implementation(...) or kapt(...).
Using BOM to Align Room Libraries
With the Bill of Materials (BOM) system, you can avoid per-library versioning:
dependencies {
implementation(platform("androidx.room:room-bom:2.5.2"))
implementation("androidx.room:room-runtime")
implementation("androidx.room:room-ktx")
ksp("androidx.room:room-compiler")
}
Benefits:
- Makes sure versions within the BOM work together.
- You need fewer config updates when you upgrade Room parts.
KSP vs. KAPT: A Strategic Decision
Both tools do the same thing: annotation processing. But the choice depends on what other tools you use and if they work together.
Choose KSP If:
- Your annotation processors (like Room or Moshi) officially support it.
- You build mostly in Kotlin.
- You want faster build times and faster incremental compiles.
Stick to KAPT If:
- You use Java-based annotation processors that have not moved to KSP.
- You use older libraries.
“Kapt still works fine, but expect long-term focus and improvements to center around KSP.” — Google, 2023
Pre-Sync Verification Checklist
Before you run the first Gradle sync:
Is the KSP plugin applied with a matching Kotlin version?
Are repositories like Google and MavenCentral enabled?
Are KSP-specific scopes (ksp(...)) used for annotation processors?
Is Room 2.4.0 or higher used for Kotlin and KSP compatibility?
Are you using BOMs or Version Catalogs to keep things consistent?
By checking these things ahead of time, you’ll avoid most Gradle sync errors and plugin problems.
Make It Reusable: Create Your Own Skeleton Project
Once you fix and set up a working Room-KSP configuration:
- Save it as a template you can use again.
- Use version control for your Gradle setup.
- Make GitHub gists or internal documents to share setups with your team.
To avoid problems, it's not enough to just know the fix. You need to build a system so you don't run into the same issue again.
Look for more practical setups in our Room and Gradle tutorials.
Citations
JetBrains. (2022). Kotlin Symbol Processing (KSP) overview. Retrieved from https://kotlinlang.org/docs/ksp-overview.html
Tencent. (2022). KSP GitHub repository. Retrieved from https://github.com/google/ksp
Android Developers. (2022). Room release notes. Retrieved from https://developer.android.com/jetpack/androidx/releases/room
Google. (2023). Kotlin Symbol Processing. Android Developers Blog. Retrieved from https://medium.com/androiddevelopers/ksp-1-0-108ebcc5f206