What dependency injection for Android with Kotlin do you prefer? I have started using Kodein but i don't want to lose my time if Koin it's better.
I have read this presentation https://www.kotlindevelopment.com/koin-vs-kodein/ by Makery Kotlin Development it's really nice.
From that presentation these are the differences:
Kodein
Koin
Github stars Kodein 1164 vs 1350 Koin
Thanks !!
As I mentioned before Dagger/Hilt has a significant impact on build time due to code generation. On the other hand, Koin also affects time, but not build, but runtime. Koin has slightly worse runtime performance, because it resolves dependencies at runtime.
Koin is a dependency injection framework for Kotlin. It is lightweight, can be used in Android applications, is implemented via a concise DSL, and takes advantage of Kotlin features like delegate properties rather than relying on annotations.
What is Kodein? Kodein (for KOtlin DEpendency INjection) is a DI framework. It allows you to bind your business unit interfaces with their implementation and thus having each business unit being independent. If you are not familiar with Kodein, its pros / cons, etc go ahead and check documentation (it is great).
One thing to note is out of the three, technically only Dagger uses a dependency injection (DI) pattern; Koin and Kodein are service locators.
As my project is small I prefer Koin, because is lightweight library. It has a good API for scopes and wrapper for VM from Android Architecture Components. But you should know that Koin looks like Service Locator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With