ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Follow publication

Member-only story

Hold on ✋🏻 Before you Dagger or Hilt! try this Simple DI.

Chetan Gupta
ProAndroidDev
Published in
6 min readSep 25, 2020

--

Learn Pure Native Kotlin DI, which can be migrated to HILT or Dagger in few steps.

Featured on :

Don’t miss out on the course on Generative AI using Kotlin, Jetpack Compose, Langchain4j, and Ollama. You will learn hands-on by building 6 AI apps. Join now for lifetime access, but hurry — prices increase after July 1st!

Sample project completely demonstrating Manual DI

Dagger is one of the popular frameworks that has been known for Dependency Injection (DI) for Java and Android platforms. It’s in most of the Android projects whether small or large, developers tend to start off with the basic scaffold of Dagger just not to deal with the huge boilerplate or to avoid huge migration of adding it later to the project. So it has become a fact that it would be present in any Android project you work in, and you will be expected to know how to use it.

Many beginners and Intermediate developers tend to scare away from it, not because of DI as a concept they perfectly understand that, but from the confusion of all wiring and learning involved how Dagger resolving their dependencies. This problem also was understood by Google devs and Hilt was their answer to it. What Hilt basically does — it abstracts all the major wiring code related to AppComponent and now the user just needs to create modules to resolve your dependencies and with some hilt scoped annotation you can do no-brainer injections.

Still, there is some learning overhead involved, when you will encounter errors in HILT, they would easier to resolved when you have working knowledge of Dagger, which again could be a lot of learning and exploring for a Junior Dev need, which doesn’t have…

--

--

Published in ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Written by Chetan Gupta

Android & Kotlin Expert | Training & Technical writing for Bussiness contact https://t.me/ch810

Responses (5)