Dependency injection with dagger

We used dagger for dependency injection and had the problem when using @Singelton an a subcomponent. When we tried to compile, we always got an error. The main componeten also used the @Singelton.


Once we've used dagger for an android project - it's capable and does some very neat stuff with dependency injection although it may be a complex beast once you dive a bit deeper so I can relate. Although the problem description is a bit superficial and the context is missing (Was this an Android project? What did you want to achieve with DI? What was the error?) it gives one a first glimpse of the complexity of the framework by mentioning scoping.
Artur Marcin Sz... - Sun, 12/09/2018 - 20:51 :::
1 answer

The solution was that a subcomponent cannot have the same scope as its parent. So the scope had to be changed, or no subcomponent should be used.