Member-only story
Dagger/Hilt vs. Koin for Jetpack Compose Apps
Advantages and disadvantages of Dagger and Koin
Ahh, here we go again. The eternal struggle between Dagger/Hilt and Koin. I expect a lot of arguments again in the comments about which one is better, but don’t worry guys, this article was created only to show you the main differences between them. Both of them are great, so you have to choose which one you want to use on your own, but I hope I’ll make this choice a little easier for you by showing you their advantages and disadvantages for Jetpack Compose apps!
For the purposes of this article I’m gonna assume that you already know what Dependency Injection is and what are the main differences between Dagger/Hilt and Koin, for example:
- Code generation vs. no code generation
- Impact on build time vs. impact on runtime and injection time
- And obviously Hilt is recommended and maintained by Google, while Koin is not. Of course, Google does not say that Koin is bad and to use what you think fits better to your project.
Here’s Manuel Vivo’s opinion about Koin, for example:
Google recommends Hilt for Android apps but that’s just a recommendation! Use what you think it’s good for you.
If none of this sounds familiar then you should probably stop reading for a moment and first figure out what Dependency Injection, Dagger, Hilt and Koin are before continuing.
Let’s roll
Okay, so now let’s compare Dagger/Hilt and Koin.
To best present the Pros and Cons of each of these tools, I will consider two cases where you can use Jetpack Compose to write Android Apps:
- The first case — when your app is written in pure Jetpack Compose, that is, without using Fragments, so you’re probably using navigation-compose library.
- And the second case — when…