Kotlin 1.1.3-2 Maven Central Travis MIT License GitHub issues Slack channel Donate

KOtlin DEpendency INjection

Kodein is a very simple and yet very useful dependency retrieval container. it is very easy to use and configure.

Kodein works:

  • On the JVM.
  • On Android.
  • On Javascript (both in the browser and on Node.js).

Kodein allows you to:

  • Lazily instantiate your dependencies when needed
  • Stop caring about dependency initialization order
  • Easily bind classes or interfaces to their instance or provider
  • Easily debug your dependency bindings and recursions

An example is always better than a thousand words:

val kodein = Kodein {
    bind<Dice>() with provider { RandomDice(0, 5) }
    bind<DataSource>() with singleton { SqliteDS.open("path/to/file") }

class Controller(private kodein: Kodein) {
    private val ds: DataSource = kodein.instance()

Kodein is a good choice because:

  • It is small, fast and optimized (makes extensive use of inline)
  • It proposes a very simple and readable declarative DSL
  • It is not subject to type erasure (as Java is)
  • It integrates nicely with Android
  • It proposes a very kotlin-esque idiomatic API
  • It can be used in plain Java

Read more

Kodein 5.0 is in Beta!

Kodein version 4 is the current major version available:

If you are currently using a javax.inject compatible dependency injection library and whish to migrate to Kodein, there is a guide for that.

If you are still using version 3, you can access version 3 documentation.


Support is held in the Kodein Slack channel. You can get an invite to the Kotlin Slack here.




salomonbrys by kodein

At Collokia we use Kodein in all of our backend service infrastructure and all modules in those services are loosely coupled through injection with Kodein. It allows us to have nice module independence, and to opt-out of injection during testing or build separate modules in support of testing.
It is a key component and building block in our architecture.
Jayson Minard



salomonbrys by kodein

At Moovel Group GmbH, we have successfully used the wonderful Kodein library into in this Android app. As we improved it, we found Kodein to be much more useful than Dagger2 as it simplified our code throughout.
Kodein is in my view, much easier to understand, doesn’t have that nasty ceremony, and has really nice debug messages.
We are also working now on other projects where we are using Kodein as well.
Sorin Albu-Irimies



salomonbrys by kodein

Kodein has been instrumental in moving our entire production application to Kotlin at InSite Applications. It uses standard Kotlin idioms and features for ultimate clarity and simplicity. It was clear to us from the beginning that Kodein would be our DI solution. Our devs love it so much that they’ve transitioned to using it in their personal apps, both Java and Kotlin!
Eliezer Graber



salomonbrys by kodein

At Compsoft Creative, Kodein is central our new Kotlin based app architecture, giving us a solid underpinning to all apps we develop and allowing a simple yet powerful way to de-couple our services with a library that is lightweight and perfect for mobile apps.
Daniel Payne



salomonbrys by kodein

Kodein is used in the android app of the OhelShem school.
Yoav Sternberg 


salomonbrys by kodein

Kodein was created at Dental Monitoring with the opinion that Dagger2 is way too verbose and complex. It is now used in almost all our projects: the server, the internal production software & the Android application.
Kodein is very easy to use and set up: it allows our team to easily share code and patterns, as well as quickly bootstrapping new ideas.
Salomon Brys



If you are using Kodein, please let me know!

compile "com.github.salomonbrys.kodein:kodein:4.1.0"

Related Libraries


Kotlin extensions for Java 8 java.time API

Last updated 3 mins ago


Vavr integration for Kotlin

Last updated 3 mins ago


Minimalist dependency injection library for Kotlin.

Last updated 3 mins ago


Simple unit conversion library for Kotlin

Last updated 3 mins ago


Simple parser combinator library for Kotlin

Last updated 3 mins ago