https://kotlinlang.org logo
#dagger
Title
# dagger
l

Lubomir Pisk

11/09/2023, 8:33 AM
Hello, I have a Kotlin Multiplatform project. Is possible to use Dagger in androidMain and access classes from commonMain (superclasses)? Thank you.
a

Arun

11/09/2023, 8:34 AM
https://github.com/evant/kotlin-inject is a better choice for multiplat
👍 1
l

Lubomir Pisk

11/13/2023, 9:05 AM
@Arun I have an existing project, you didn't reply my question.
t

Tim Malseed

11/13/2023, 10:46 AM
It is possible, yes. Just add the dagger/hilt plugin to your module’s build.gradle, and perform your DI logic in the androidMain source set
The classes don’t need to be ‘superclasses’ - they can just be regular commonMain classes. Your dagger @Module is just defining how to provide instances of those classes. You don’t need expect/actual or whatever
3 Views