I have migratin my build to use version catalogs.
I have remove the following from my build.gradle
plugins {
id 'kotlin-android'
id 'kotlin-kapt'
}
and
kapt "androidx.room:room-compiler:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
now I am getting
warning: The following options were not recognized by any processor:
'[dagger.hilt.internal.useAggregatingRootProcessor, room.schemaLocation,
dagger.fastInit, dagger.hilt.android.internal.disableAndroidSuperclassValidation,
dagger.hilt.android.internal.projectType]'
1 warning
and
A failure occurred while executing
com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'META-INF/gradle/incremental.annotation.processors' from
inputs:
- /.gradle/caches/transforms-
3/5f588ae3973231906376832b3350f55d/transformed/jetified-hilt-android-compiler-
2.45.jar
- /.gradle/caches/transforms-
3/f1c91d9e7fbd546100043f736678c477/transformed/jetified-dagger-compiler-2.45.jar
Now I am wondering how to add kotlin-kapt
as plugin the version catalogs.
Or how do I use the annotationProcessor
with version catalogs?
2
Answers
First, change the plugins in build.gradle(:app) like:
Then implement the libraries in libs.version.toml file like shown below:
Last, import the libraries in build.module(:app), you can use
kapt
orannotationProcessor
:And do not forget to add this in build.gradle(project), if you didn’t already:
libs.version.toml
build.gradle(:project)
build.gradle(:app)
For more detail visit this website:
https://www.droidcon.com/2022/05/13/gradle-version-catalogs-for-an-awesome-dependency-management/