컴퓨터/이론: 개발
[2018.05.02] 02. Dagger2 error - Activity Injection
heepie
2018. 5. 2. 18:37
문제점
원인
Activity를 inject 할 때는 추가적으로 ActivityModule을 생성해 Component에 추가해야 한다.
해결책
Step1. ActivityModule 생성
Step1. ActivityModule 생성
1 2 3 4 5 6 | @Module interface ActivityModule { @ContributesAndroidInjector fun contributeSampleActivity(): SampleActivity ... } | cs |
Step2. Component에 추가
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | @Singleton @Component(modules = [ AppModule::class, ActivityModule::class, AndroidSupportInjectionModule::class ]) interface AppComponent: AndroidInjector<LxApplication> { @Component.Builder interface Builder { @BindsInstance fun application(application: Application): AppComponent.Builder fun build(): AppComponent } } | cs |
#Dagger2 Error #No Injector