how to use hilt with ksp instead of kapt seems like i can't figure it out please let me know what dependencies should i add and how should i add them
dependencies i added:
//hilt
val hiltVersion = "2.51"
implementation("com.google.dagger:hilt-android:$hiltVersion")
ksp("com.google.dagger:hilt-android-compiler:$hiltVersion")
ksp("com.google.dagger:hilt-compiler:$hiltVersion")
plugins:
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id ("com.google.dagger.hilt.android")
id("com.google.devtools.ksp") version "1.9.22-1.0.17"
}
build gradle:
plugins {
id("com.android.application") version "8.2.2" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
id("com.google.dagger.hilt.android") version "2.51" apply false
id("com.google.devtools.ksp") version "1.9.22-1.0.17" apply false
}
i tried different hilt versions like 2.48.1 different kotlinCompilerExtensionVersion like 1.5.8
nothing seems to work i've got multiple different errors don't know what i'm doing neither do i know what i'm doing wrong
When using kotlin
, ksp
and compose
you have to keep in mind to use versions that are compatible with each other, otherwise building the project will most likely fail.
Kotlin and KSP
Take a look at releases, ksp version always consist of two parts e.g. 1.9.23-1.0.20
where 1.9.23
is kotlin version and 1.0.20
is actual KSP version (i think).
Kotlin and Compose
List of compatible versions can be found in Android docs.
Your case
Since you are using kotlin 1.9.0
you should use KSP 1.9.0-1.0.13
and kotlinCompilerExtensionVersion 1.5.2
. For the dagger it should word fine for version 2.48
and above based on this, so version 2.51
is fine.