Dependency Injection with Koin on Android.

Raviraj Desai
2 min readJun 11, 2022

--

A pragmatic lightweight dependency injection framework for Kotlin developers. Written in pure Kotlin using functional resolution only: no proxy, no code generation, no reflection!
Office Website — https://insert-koin.io/

Why Koin?

Koin is easy, simple & well documented. It is perfect for encapsulated feature/library modules.

How Koin Works ?

The koin works on simple DSL model. Here we have to create module first. In this module all the dependent objects are there, then we have to load one or more modules in koin. Then, we are ready to use this object. Generally we are loading module in to koin in application class by calling startKoin method,then we can inject the object wherever we want,this how the Koin works.

With Koin, setting up dependency injection is kind of a manual process, you essentially plug your services into the module graphs and those dependencies will later get resolved at runtime.

Lines of code

If you just want to download the code and check it by yourself, the repository is :

https://github.com/rajextreme9476/KoinDISample

--

--

Raviraj Desai
Raviraj Desai

Written by Raviraj Desai

Assistant Vice President at HDFC Bank (Android — Kotlin lover. Tech stack: MVVM, Dagger2, Coroutines, RxJava2 ,Flutter Enthusiast ,Ejabber