Setting Up Android Modules With Dagger 2
Modular development is the way forward
Published in
5 min readSep 15, 2019
In professional app development, the days when all Android code lives in a single gigantic app module will soon be over. Modular development is the way forward. Modularity promotes proper architecture set-up consideration and scalable development.
If we start a project with modularization in mind, we can set up the dependencies injection using Dagger 2. This piece will show you how, with a simple project illustration.
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…