Dagger tips: elegantly handle your Activities and Fragments by AndroidInjector

wang.chauyan
8 min readAug 5, 2019
Android + Dagger2

I recently see many people have troubles with Google Dagger2 lib. To be honest, I think those Googlers should be carefully considering there are so many noobs like me can’t totally understand what their document exactly means.

That’s the reason why I decided to write a sample for Dagger2 and reuse it in the future as a boilerplate without rewriting too many codes for it. Let’s start from the very beginning — create an Android App first.

Create a new project.

Pretty straightforward. Let’s Go.

Modify App module Gradle file

1. add kaptplugin
2. add dagger gradle implementations

// dagger implementations
kapt…

--

--