Dagger is a fully static, compile-time dependency injection framework for Java, Kotlin, and Android. It is an adaptation of an earlier version created by Square and now maintained by Google. The latest Dagger release is: Dagger 2.33. Dagger aims to address many of the development and performance issues that have plagued reflection-based solutions. Dagger is a replacement for the FactoryFactory classes that implements the dependency injection design pattern without the burden of writing the boilerplate. It allows you to focus on the interesting classes. Declare dependencies, specify how to satisfy them, and ship your app. Dependency injection frameworks have existed for years with a whole variety of APIs for configuring and injecting. So, why reinvent the wheel? Dagger 2 is the first to implement the full stack with generated code. The guiding principle is to generate code that mimics the code that a user might have hand-written to ensure that dependency injection is simple.
Features
- Simple, traceable and performant dependency injection
- Dagger constructs instances of your application classes and satisfies their dependencies
- Dagger can inject fields directly
- Dagger also supports method injection
- Dagger associates scoped instances in the graph with instances of component implementations
- Components may have multiple scope annotations applied