
Explore the history and foundations of dependency injection and learn how Dagger enables components, modules, providers, and bindings to implement runtime injections, singletons, and real-world refactoring.
This lecture explains the Udemy review system, notes that reviews influence course standing and visibility, and invites you to message for improvements or to leave a positive 5-star review.
Explore dependency injection in a general, abstract way; distinguish it from Dagar, review Java annotations, and examine the history and benefits of Dagar for Android development.
Learn how Dagger 2 uses dependency injection to replace boilerplate with generated code, supports Java and Kotlin on the JVM, and manages dependencies via components.
Explore Java annotations and how Dagger uses the at symbol metadata to inject services, mark code elements, and define built-in and custom annotations for dependency injection.
Dagger's evolution from Square's reflection-based prototype to Google's generated code approach. Learn how code generation, annotations, and reduced boilerplate enable reusable, memory-efficient dependency injection.
Set up a new project and Gradle for dagger, then explore the component annotation—the backbone of dagger—and examine constructor, field, and method injection.
Create a new Android Studio project with an empty activity set to minimum sdk 16, then add dagger 2 dependencies and the annotation processor in Gradle.
Learn constructor injection with Dagger by building a car component that creates and injects engine and wheels via a dependency graph, with Dagger generating the necessary code for main activity.
Explore field injection in dagger 2 by annotating non-private, non-final fields with @Inject and using a component to create and inject those fields into Android classes.
Method injection is the third dagger injection type, injecting dependencies into methods. Use @Inject on a non-private, non-final method, following the constructor and field injections order.
Learn how modules integrate third-party libraries into the Dagger dependency graph, and use the provides and binds annotations to inject values at runtime in Android development.
Define a module to contribute to the dependency graph and inject third-party classes; use @Module and @Provides to supply objects for injection, and attach modules to components.
Learn how the binds annotation binds interfaces in Dagger 2, using abstract modules and abstract functions for efficient dependency binding, and avoid binding the same interface in multiple modules.
Perform a code refactor by relocating diesel engine, petrol engine, and wheels modules into a new package designed for dependency injection, with remaining components in a model package.
Explore how custom builders override the default builder and how bind instances supply values to the dependency graph. Examine named annotations, Dagger's generated code, and the singleton pattern in practice.
Override the default Dagger component builder with a custom builder to inject values. Use the bind instance annotation to bind horsepower into the dependency graph.
Learn how named annotations differentiate multiple injections of the same type in Dagger, by mapping horsepower and engine capacity integers with @Named identifiers, ensuring correct injection in the petrol engine.
Visualize the dagger graph and generated code for the car component with scabbard, uncovering wheels, engine, and remote dependencies, and understand dagger's builders and factories.
Explore the singleton pattern with Dagger, using the @Singleton annotation to provide a single driver across multiple cars via a shared dependency graph.
Explore the section structure and master Dagger 2 concepts by detailing component scope and lifecycle, creating custom scopes, and using subcomponents, builder, and component factory.
Define a custom Dagger 2 scope by creating a scope annotation and applying it to an activity-scoped car while the driver remains application-scoped, and connect them via a component dependency.
Explore how subcomponents extend a parent component, manage smaller scopes, and access the parent dependency graph, enabling separation of concerns and flexible lifecycle in Dagger 2.
Explore how to implement a subcomponent builder in dagger 2, using horsepower and engine capacity to configure the petrol engine module, build the car component, and inject dependencies.
Discover the Dagger component factory, a single create method that enforces all required data, offering compile-time safety and a contrast with the builder pattern.
Explore a simple mvvm Android app that fetches countries from a backend via retrofit, displays them in a recycler view, and sets up dagger-based dependency injection for future wiring.
Learn how to implement constructor and field injection with Dagger by turning the country service into a singleton provided to the Dagger graph and injecting it into the view model.
Set up Dagger for Android, make the country service injectable as a singleton, define a component, and enable constructor and field injection into the view model.
Inject the country list into main activity by creating a module to instantiate the array list, updating the component to include the module, and performing the injection in main activity.
Define a Dagger 2 module to provide the country list adapter via a static @Provides method in a companion object, then inject it into the main activity through components.
Refactor the country list to an activity scope and the country service to an application scope, configuring scopes, app and country components, and injections for rotation-safe recreation.
Implement activity scope for the country list adapter and application scope for the country service, using Dagger components and a custom builder to manage lifecycle and dependencies.
Thank you for participating and completing the course; celebrate your achievement as an Android developer. Apply the concepts learned to your projects and to your work as an Android developer.
Dependency Injection is now an indispensable component of Android development. All well built, large projects use it to make development easier and more practical.
Dagger2 is the most widely used framework for DI in Android.
This course will
take you from a complete beginner in the technology
explain in detail the theoretical aspects of Dagger 2 injection
exhaustively go through all the components that make Dagger2 such a successful library
implement it in a practical application, to show you a real world scenario
After this course you will have the knowledge and experience to use Dagger2 in all your app development projects, and will allow your apps to grow and expand seamlessly.
We will learn about:
Dagger history and advantages
Component
Module
Annotations
Constructor injection
Field injection
Method injection
Singleton pattern
Custom components
Subcomponents
Component factory
Practical work
We will build everything in Kotlin.
We cover a lot of ground in this course, and we will implement the concepts practically so that you get not only theoretical knowledge but practical experience as well.
Sign up today, and let's learn how to use Dagger2 to build a modern Android Application.