Hilt vs Koin vs manual DI

Architecture and dependency injection Mid-level Kotlin 2.0+ API 24+ Reviewed By Best Latest Apps

Pick the fix

A team is starting a Kotlin Multiplatform app sharing ViewModels and repositories with iOS. Which DI choice fits shared code?

Options
Hint 1 of 1

Which frameworks run on iOS?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Koin or manual DI in the shared module

Correct. Hilt only runs on Android, so it can't wire shared code for iOS.

Why not the others?
  • B Hilt in the shared module. Hilt depends on Android and Dagger code generation for the JVM.
  • C No DI; create everything with constructors inside classes. Hard to test, and lifetimes become ad hoc.
  • D Dagger 1. Long obsolete.

30-second answer

Hilt is built on Dagger and generates the dependency graph at compile time, so missing bindings fail the build and runtime cost is low; it has Android-specific components and is Google's recommendation. Koin is a Kotlin DSL that resolves dependencies at runtime, simple to set up and Multiplatform-friendly, but errors appear when the app runs unless you add checks. Manual DI with a container class is fine for small apps and libraries.

Practise saying it · 35 s. No recording, just a timer

Compare Hilt, Koin and manual DI.

Say your answer out loud, then check which of these points you covered:

  • Hilt: compile-time, Android
  • Koin: runtime DSL, KMP-friendly
  • Manual DI for small apps
  • Constructor injection either way

Deep dive

Hilt's annotation processing adds build time; KSP support reduces it.

Koin offers verify() and an annotations module with compile-time checks.

For Kotlin Multiplatform, Koin or manual DI work in shared code; Hilt is Android-only.

Whichever you choose, constructor injection keeps classes independent of the framework.

Common mistakes

  • Choosing by popularity instead of build time, KMP and safety needs.
  • Mixing two DI frameworks in one app.
  • Letting framework annotations spread into domain classes unnecessarily.

Senior take & follow-ups

Give trade-offs rather than a winner; tie the choice to project needs.

Follow-up questions

Think of your answer first, then open the hint.

  1. Which works in KMP shared code?

    Show hint

    Koin or manual DI; Hilt is Android-only.

  2. When is manual DI enough?

    Show hint

    Small apps, samples and libraries.

Suggest a fix if something here is wrong or out of date.