Setting Up Android Modules With Kodein
Comparison with Koin and Dagger 2
Published in
6 min readSep 25, 2019
As I have already explored Koin and Dagger 2 for application in multi-module Android projects, to complete my tour of duty, I should not leave Kodein out. It is the other popular dependency injection framework in Android, powered by Kotlin.
Note: Another similar framework is Injekt, which is stated as very similar to Kodein.
Let’s look at how it is done here.
Project Assumptions
Here’s how we’ll set up our simple project:
- There are three activities, where
MainActivity
could launchFeatureOneActivity
orFeatureTwoActivity
. - Each of the activities has its own dependency injected to it.
- Each of the dependencies is injected with a singleton network and repository (i.e., the same copy is injected to all dependencies.
Project Modularization
For long-term scalability, assume we modularize based on activities. We could do it in other forms as well, this is just to simplify the illustration.