If you’re building an Android app using Kotlin and annotation processors such as Dagger, Hilt, Room, or Moshi, chances are you’ve faced this common issue: kapt is not generating code as expected. This can be frustrating, especially when your build passes but the generated classes are simply missing. Fortunately, there are practical steps you can take to fix this problem and restore kapt’s code generation.

Why kapt Might Not Generate Code
There are several possible reasons why kapt (Kotlin Annotation Processing Tool) fails to generate code:
- Incorrect plugin configuration
- Missing dependencies or kapt-specific annotations
- Improper Gradle setup
- Caching issues
- Outdated Kotlin or kapt versions
Let’s walk through the recommended solutions.
Apply the Correct Plugins
Make sure your build.gradle
(module level) includes both the Kotlin and kapt plugins:
plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-kapt' }
Without kotlin-kapt
, the annotation processor won’t be triggered.
Use kapt-specific Dependencies
Ensure you’re using the correct kapt version of your dependencies. For example, with Hilt:
implementation "com.google.dagger:hilt-android:2.48" kapt "com.google.dagger:hilt-compiler:2.48"
Using only implementation
for processors will prevent kapt from running.
Clean and Rebuild the Project
Sometimes Gradle or IDE cache gets in the way. Run these commands to force regeneration:
./gradlew clean build
Also, try File > Invalidate Caches / Restart in Android Studio.
Enable Annotation Processor in IDE
In Android Studio, go to:
Preferences → Build, Execution, Deployment → Compiler → Annotation Processors
Make sure it’s enabled for your project.
Update Kotlin and kapt Versions
Outdated tools can break kapt. Always sync with the latest Kotlin version and kapt-compatible libraries. You can check the latest versions on MVNRepository.
Final Thoughts
Kotlin’s kapt is powerful but sensitive to configuration. Follow these steps to diagnose and resolve kapt not generating code issues in your Android project. Always keep dependencies up to date and configure Gradle properly to ensure smooth code generation.