Понятия не имею, почему мой DaggerComponent не создается после перестройки проекта.
@Scope
@Retention(AnnotationRetention.RUNTIME)
annotation class NewsScope
@NewsScope
@Component(
dependencies = [BaseComponent::class],
modules = [NewsModule::class]
)
interface NewsComponent {
fun newsManager(): NewsManager
}
@NewsScope
@Component(
dependencies = [BaseComponent::class],
modules = [NewsModule::class]
)
interface NewsComponent {
fun newsManager(): NewsManager
}
@Module
class NewsModule {
@NewsScope
@Provides
fun provideMoshiConverterFactory(): MoshiConverterFactory {
val moshi = Moshi.Builder().build()
return MoshiConverterFactory.create(moshi)
}
@NewsScope
@Provides
fun provideNewsApi(okHttpClient: OkHttpClient): NewsApi {
val moshi = Moshi.Builder().build()
val retrofit = Retrofit.Builder()
.client(okHttpClient)
.baseUrl(NewsApi.API_URL)
.addCallAdapterFactory(RxJavaCallAdapterFactory
.createWithScheduler(Schedulers.io()))
.addConverterFactory(MoshiConverterFactory.create(moshi))
.build()
val retrofitApi = retrofit.create(RetrofitNewsApi::class.java)
return RetrofitNewsApiImpl(retrofitApi)
}
@NewsScope
@Provides
fun provideNewsManager(newsApi: NewsApi): NewsManager {
return NewsManager(newsApi)
}
}
class NewsFragment : BaseFragment() {
@Inject lateinit var newsManager: NewsManager private set
override fun onCreate(savedInstanceState: Bundle?) {
newsManager = DaggerNewsComponent.builder()
.baseComponent(baseComponent())
.newsModule(NewsModule())
.build().newsManager()
}
}
- *** DaggerNewsКомпонент не создан
- $ dagger_version = "2.23.2"
- AndroidX был реализован
Я iOS Pro, но Android Noob
реализация "com.google.dagger: dagger: $ dagger_version"
реализация "com.google.dagger: dagger-android: $ dagger_version"
реализация "com.google.dagger: dagger-android-support: $ dagger_version"
annotationProcessor "com.google.dagger: dagger-android- процессор: $ dagger_version"
annotationProcessor "com.google.dagger: dagger-compiler: $ dagger_version"