Every Kotlin codebase eventually hits the same wall: you have a Repository, four UseCase classes, two platform-specific HttpClient implementations, and a constructor chain long enough that wiring it by hand at the Application class is now a 200-line function nobody wants to touch. You reach for a dependency injection framework — and discover the Kotlin ecosystem has three answers that disagree about something fundamental: when dependencies get resolved.
Koin resolves at runtime with a DSL. Kodein resolves at runtime with a typed container. kotlin-inject generates the wiring at compile time with KSP. That single difference decides your build times, your crash profile, and whether your shared module works on iOS.
Here’s the 2026 comparison, with live repository data and the setup code each one actually requires.
TL;DR — the blunt verdict
- Koin 4.1 if you want the shortest path to working code and can tolerate runtime failures. It has the biggest community (10K stars), first-class Compose and KMP support, and a compiler plugin that now catches most graph errors at build time.
- kotlin-inject 0.8 if your shared code targets iOS and you refuse to ship a graph that can fail at runtime. Compile-time verification, no reflection, no service loader — but you pay with KSP build time and a smaller ecosystem.
- Kodein 7.26 if you already run it, or if you specifically want a container you can pass as a plain object (
DI) rather than a global singleton. It’s mature, typed, and far less fashionable than it was in 2019. - Dagger/Hilt only when you’re already on Android with Hilt conventions — see our Java DI comparison of Dagger, Koin and Guice for the JVM-side story.
If I had to pick one for a new KMP project in December 2026: kotlin-inject for shared modules, Koin only if the team is new to DI.
Comparison table (live data, December 2026)
| Koin | Kodein | kotlin-inject | Dagger/Hilt | |
|---|---|---|---|---|
| GitHub stars | 10,030 | 3,336 | 1,501 | 17,690 |
| Last commit | 2026-11-06 | 2026-11-03 | 2026-01-07 | 2026-12-02 |
| Resolution | Runtime DSL (+ compiler plugin checks) | Runtime typed container | Compile time (KSP) | Compile time (KAPT/KSP) |
| Maven coordinate | io.insert-koin:koin-core | org.kodein.di:kodein-di | me.tatarka.inject:kotlin-inject-runtime | com.google.dagger:dagger |
| Current version | 4.1.0 | 7.26.1 | 0.8.0 | 2.x |
| KMP support | Yes, official | Yes | Yes, primary design goal | Partial (KMP artifacts lag) |
| Compose integration | koin-compose | Kodein-Framework | Manual / component passing | hilt-navigation-compose |
| Reflection | None | None | None | None |
| Graph errors caught | Build (plugin) or runtime | Runtime | Build | Build |
| Learning curve | Low | Medium | Medium-high | High |
| Best fit | Apps, Compose, teams new to DI | Container-passing architecture | Shared KMP modules, libraries | Android apps on Hilt |
Decision matrix — pick in 10 seconds
| Your situation | Use | Why |
|---|---|---|
| Android-only app, Compose, small team | Koin | viewModel {} DSL, module organization, minimal boilerplate |
| KMP shared module used by iOS and Android | kotlin-inject | Compile-time graph, no runtime surprises on Kotlin/Native |
| You need the container as a value, not a global | Kodein | DI is an object you inject, not a static registry |
| Library/SDK you publish to others | kotlin-inject | Consumers can’t break your graph at runtime |
| Migrating from Koin 3.x | Koin 4.1 | Same DSL, annotations module, current plugin |
| Legacy Android with Hilt already configured | Hilt | Don’t fight the framework you inherited |
| Multi-module build where build time is critical | Koin | No annotation processing on the hot path |
| Strict correctness, regulated domain | kotlin-inject | Missing binding = compile error, not crash |
Koin 4.1 — the pragmatic default
Koin’s pitch is that DI shouldn’t require code generation. You declare modules in a DSL, start the container, and resolve:
| |
| |
That’s it — no annotations, no generated code, no @Inject constructor. The cost is obvious: if you forget to declare ApiClient, you find out when the screen opens and NoBeanDefFoundException is thrown. Koin 4 mitigates this with Koin Annotations plus the Koin Compiler Plugin, which verifies module graphs during compilation:
| |
With the compiler plugin enabled, missing definitions and circular dependencies fail the build instead of the app. In practice you get most of compile-time safety while keeping the DSL’s readability. Enable it if you’re on Koin 4 — running without it in 2026 is leaving the main improvement of the last two major versions unused.
Where Koin genuinely wins is Compose and Android integration. koinViewModel() slots into the Compose lifecycle, scopes map onto NavBackStackEntry, and module organization scales from a 20-screen app to a super-app without ceremony. If your team has never used a DI framework, Koin is the one they’ll understand by lunchtime.
Where it loses: Kotlin/Native. Runtime reflection isn’t the issue (Koin doesn’t use it), but the global container and startKoin initialization order are awkward in shared code that iOS calls from Swift. It works — teams do ship Koin in KMP — but you’re carrying a runtime registry into a platform that would rather you pass a component.
kotlin-inject 0.8 — compile-time wiring, no ceremony tax
kotlin-inject is the smallest of the three in stars and the strictest in philosophy: the graph is generated, so an unsatisfiable dependency is a compile error.
| |
| |
Scopes and platform-specific bindings use annotations rather than module declarations:
| |
The @Component argument accepts another component, which is how you share bindings between commonMain and platform source sets: declare the interface in common, provide the platform implementation with @Provides in androidMain or iosMain, and the generated code resolves against whichever source set is compiling. That’s the KMP story, and it’s why kotlin-inject exists.
The trade-offs are real:
- KSP build time. Every
@Inject/@Componentadds processing. On a large module, incremental builds get slower than Koin’s zero-processing approach. - Smaller ecosystem. Fewer StackOverflow answers, no
viewModel {}DSL, no Compose helper — you pass the component down or hold it in a CompositionLocal yourself. - Pre-1.0 versioning. 0.8.0 with a 0.9.0 line in the README; API churn is possible. Pin your version and read release notes.
- Last commit January 2026 versus November for the other two. Not abandoned, but not fast-moving either. For a compile-time tool with a small surface, that’s acceptable — for a framework you plan to build a five-year product on, note it.
Kodein 7.26 — the container you can hold
Kodein’s distinguishing feature isn’t the DSL; it’s that the container is a value. You pass a DI instance around like any other object, which makes testing and multi-tenant code much cleaner than a global registry.
| |
| |
Three things Kodein does better than Koin:
- Explicit container passing.
OrdersPresenter(di)in a test takes a container you built for that test — no global state to reset between tests. - Typed bindings with tags and multi-bindings.
bind<Plugin>() with multitonandinstance(tag = "retry")are first-class, which suits plugin architectures. - Kodein-Framework covers Android, Compose, and KMP with the same mental model.
Three things it does worse:
- Mindshare. Tutorials, sample apps, and hiring familiarity all skew toward Koin. Onboarding cost is a real cost.
- Verbosity.
DIAwareplus delegatedinstance()properties is more ceremony thanmodule { single { } }. - Momentum. Commits in November 2026 but a slower release cadence and a much smaller Compose ecosystem than Koin’s.
Kodein is the correct answer for a specific architecture — container-as-dependency, heavy testing, plugin-style extension — and a defensible answer for everyone else. It is rarely the wrong choice; it’s just rarely the fashionable one.
Pitfalls that bite in production
Don’t mix get() lazily inside a singleton factory and expect deterministic init order. In Koin, single { Repository(get()) } resolves get() at first resolution, not at module load. If Repository starts a background job in its constructor, that job now runs whenever the first screen asks for it — which in Compose may be during a recomposition. Prefer explicit createdAtStart for infrastructure singletons.
Compose + ViewModel scoping is where Koin graphs leak. viewModel { } binds to the ViewModel store owner; a NavBackStackEntry-scoped instance dies with the back stack entry, but a single that holds a reference to it does not. Symptom: a memory leak that only shows up after 30 navigation cycles. Scope repositories as single, screen state as viewModel, and never the reverse.
kotlin-inject component arguments must be declared in common code. If AppComponent takes ApiModule as an argument, ApiModule must exist in commonMain — you can’t pass an androidMain-only type into a common component. The fix is an expect/actual interface, which is one more layer than most teams expect on day one.
KSP version must match your Kotlin version. kotlin-inject’s compiler is a KSP processor; a Kotlin upgrade without a matching KSP bump produces IllegalStateException during processing, not a friendly message. Keep Kotlin, KSP, and kotlin-inject in one dependency-update PR.
Kodein’s instance() inside a lambda defers resolution. bind<Repo>() with provider { RepoImpl(instance()) } is lazy by design — a missing binding throws at call time, not at container construction. Build containers in tests with DI { } and resolve every root binding once to fail fast.
Reflection-free doesn’t mean zero cost. All three generate or interpret lookup structures. Benchmark your startup if you’re initializing 300+ bindings in an Android Application — Koin’s module list traversal is measurable, and splitting modules by feature with lazy loading beats one giant module.
If your DI graph wraps a serialization layer, the same discipline applies: see our Kotlin serialization comparison of kotlinx.serialization, Moshi and Klaxon for how type-safe mapping decisions interact with injected adapters.
FAQ
Is Koin fast enough for large Android apps?
Yes, with caveats. Koin resolves lazily and does no reflection, so per-resolution cost is a map lookup plus lambda invocation. The measurable cost is startup module traversal when you register hundreds of definitions. Split modules per feature and use createdAtStart only for infrastructure that must exist immediately.
Which Kotlin DI framework is best for Kotlin Multiplatform?
kotlin-inject, because compile-time generation works identically on JVM, Android, and Kotlin/Native — there’s no runtime registry to initialize from Swift. Koin works in KMP and has better Compose tooling, but shared code that iOS drives from Swift is easier to reason about when the graph is generated.
Can I migrate from Koin to kotlin-inject incrementally?
Yes, in one direction: wrap your existing Koin container behind an interface in commonMain, declare that interface as a @Provides binding in a kotlin-inject component, and migrate feature by feature. Going the other way is harder because Koin’s get() chains can’t be validated by KSP at build time.
Does Kodein still make sense in 2026?
If you want the container as an injectable value — for tests, multi-tenant apps, or plugin systems — yes, and nothing else in Kotlin does it as cleanly. If you want the largest ecosystem and the least ceremony, Koin is the safer pick. Kodein is maintained but no longer the default recommendation it was in 2019.
Do I need annotation processing for Koin?
No, the DSL requires none. But if you use Koin Annotations you need KSP, and enabling the Koin Compiler Plugin is strongly recommended in Koin 4 — it turns missing-definition runtime crashes into build failures, which is the single biggest reliability upgrade available to a Koin codebase.
What about Dagger/Hilt for Kotlin Multiplatform?
Hilt remains Android-centric; its KMP story is weaker than kotlin-inject’s and its KMP artifact cadence lags Kotlin releases. If your shared module must compile for iOS, Hilt is the wrong tool regardless of its star count. On Android-only projects, Hilt’s integration with @HiltAndroidApp and navigation is still excellent.
💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com