https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
h

Hien Nguyen

03/01/2024, 3:46 AM
I want to use hilt in androidMain of kmm project, how to setup in build gradle.kts
Copy code
androidMainImplementation(libs.hiltAndroid)
    androidMainImplementation(libs.hiltNavigationFragment)
    kapt(libs.hiltAndroidXCompiler)
    kapt(libs.hiltCompiler)
with android, it’s ok but with kapt it cannot build for iosMain
d

darkmoon_uk

03/01/2024, 5:16 AM
It won't be able to, Hilt is built for the JVM only. Two suggestions: read the Kotlin Multiplatform introductory documentation, it may clear up any misunderstanding about how KMP works. Secondly, avoid using codegen/annotation driven DI. Experience tells me it's rarely worth the problems it causes.
🙌 1
j

Jeff Lockhart

03/01/2024, 5:59 AM
Check out Koin or another library which supports KMP.
🙌 1
h

Hien Nguyen

03/01/2024, 6:35 AM
thanks guys
93 Views