I completely agree with this article. Dagger 2 is way over-engineered and I disagree with Jake Wharton's assessment that a service locator is just for toy apps. Martin Fowler thoroughly compares DI and service locators here: https://martinfowler.com/articles/injection.html#ServiceLocatorVsDependencyInjection. I think the gist is that DI is more complex (looking your way Dagger) and that added complexity needs to be justified. Every team, every app and every business is different and Koin is a good (better) choice in more cases than not IMO.

I use Koin for Ktor and love it. For Android I prefer Toothpick, it's even simpler and more concise than Koin:

https://github.com/stephanenicolas/toothpick. Unfortunately it didn't gain much traction so nowadays I would probably pick a different DI framework.

Hilt is a good effort but still over-engineered. What I particularly dislike about Hilt is that it's not platform agnostic. It shines as part of Android but if you decide to use non-standard Android components (e.g. Conductor instead of Fragments) you'll have to jump through some hoops (unlike with platform agnostic frameworks like ... well every other DI framework like Koin, Kodein and Toothpick). There's also a trend to use more generic frameworks over specialized frameworks: cross-platform frameworks (Flutter, React Native), Kotlin multi-platform, GraalVM etc.. Using a tool like Koin supporting multiple platforms (via Kotlin multiplatform) over a tool that supports a single platform (Android) makes imo sense especially if you want an environment that fosters engineers to move between areas instead of breeding the "single-purpose" engineer.




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Emanuel Moecklin

Emanuel Moecklin

More from Medium

Experience at LGM

With the Mobibi app, you can mobilise your whole team to get your business noticed

Inked Fears

Buying a Homo Spacien NFT on the MetaMask App for iOS and Android