Error:(21,1)错误:com.qt.daggerTest.AppComponent depends on scoped components in a non-hierarchical scopeordering:@com.qt.daggerTest.ActivityScope com.qt.daggerTest.AppComponent @com.qt.daggerTest.ActivityScope com.qt.daggerTest.ActivityComponent (2). @Singleton的Component不能依赖其他Component。这从...
Dagger2解析-1 Dagger2解析2-Component的依赖关系 Dagger版本:2.11 1. Module里添加subcomponents 上篇的结尾说到Module内可以再包含Component,需要注意的是,这个Component和之前的Component组件是不一样的 需要用@SubComponent注解 SubComponent里面还需要再放一个Builder, interface或者abstract class都可以,标注@Subcomponent...
Cooker mCooker;publicElectricHeater(){//DaggerMachineComponent.create().heaterComponent().inject(this);//注意这里我们用Parent的静态方法获取ComponentCoffeeMachine.getComponent().heaterComponent().inject(this);}@Overridepublicvoidheat(){mCooker.cook();Log.d(TAG,"electric heating... by: "+mCooker);...
at dagger.internal.codegen.writing.MapRequestRepresentation.getDependencyExpression(MapRequestRepresentation.java:106) at dagger.internal.codegen.writing.RequestRepresentation.getDependencyExpressionForComponentMethod(RequestRepresentation.java:43) at dagger.internal.codegen.writing.ComponentMethodRequestRepresentation.getC...
注意,在Dagger2中的单例,应该理解为在它所注解的@Scope的Component中只存在一个,这与通过private constructor + getInstance()来实现的单例有所不同 然后我们回到CoffeeMachine的代码,我们在这里通过注入增加一个Cooker的对象 publicclassCoffeeMachine{privatestaticfinalStringTAG=PublicConstant.PUB+"CoffeeMachine";@Inje...