Member-only story
Android/Kotlin Series: [#03] Kotlin plugin should be enabled before “kotlin-kapt”
1. Why did it happen?
Kotlin plugin doesn’t pick up annotationProcessor
dependencies, So we have to use kapt dependencies with kotlin-kapt
. Use the latest version of Kotlin annotation processor put this line at top of your module’s level build.gradle
file As the message says, all you have to do is you have to enable Kotlin plugin before kotlin-kapt
in app\build.gradle
. The plugin contents of app\build.gradle
the file before solving this issue are shown below.
2. How to solve it?
Now we will change the order of kotlin-kapt
and kotlin-android
with kotlin-android
coming prior to kotlin-apt
.
Change
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
to
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
Thanks for:
- https://kotlinlang.org/docs/reference/using-gradle.html
- https://kotlinlang.org/docs/reference/compiler-plugins.html
- https://plugins.gradle.org/plugin/org.jetbrains.kotlin.kapt
Thanks for reading, please feel free to comment on this post