【发布时间】:2020-11-17 14:30:51
【问题描述】:
不确定为什么构建失败。一切似乎都在检查中
class MapObjectRepositoryIMPL @Inject constructor(
@ApplicationContext context : Context,
val mapObjectDao: MapObjectDao,
val barrechatNetwork: BarreNetwork,
@DefaultDispatcher private val defaultScope: CoroutineContext
) : MapObjectRepository {
@Module
@InstallIn(ApplicationComponent::class)
object DispatcherModule {
@DefaultDispatcher
@Provides
fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default
@IoDispatcher
@Provides
fun providesIoDispatcher(): CoroutineDispatcher = Dispatchers.IO
@MainDispatcher
@Provides
fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main
}
@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class IoDispatcher
@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class MainDispatcher
@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class DefaultDispatcher
我得到的错误是这样的,但看起来我正确地提供了所有东西,限定符和对存储库类的注入,这很奇怪......
ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7.1C:\Users\Anon\AndroidStudioProjects\Barrechat192\app\build\generated\source\kapt\debug\com\example\barrechat192\BarreApp_HiltComponents.java:163: error: [Dagger/MissingBinding] @com.example.barrechat192.di.DefaultDispatcher kotlin.coroutines.CoroutineContext cannot be provided without an @Provides-annotated method.
public abstract static class ApplicationC implements BarreApp_GeneratedInjector,
^
@com.example.barrechat192.di.DefaultDispatcher kotlin.coroutines.CoroutineContext is injected at
com.example.barrechat192.data.repositories.IMPL.MapObjectRepositoryIMPL(�, defaultScope)
com.example.barrechat192.data.repositories.IMPL.MapObjectRepositoryIMPL is injected at
com.example.barrechat192.di.RepositoryModule.bindMapObjectRepository(mapObjectRepositoryIMPL)
javax.inject.Provider<com.example.barrechat192.data.repositories.MapObjectRepository> is injected at
com.example.barrechat192.ui.activities.mainactivity.barremap.BarreMapViewModel_AssistedFactory(�, mapObjectRepository)
com.example.barrechat192.ui.activities.mainactivity.barremap.BarreMapViewModel_AssistedFactory is injected at
com.example.barrechat192.ui.activities.mainactivity.barremap.BarreMapViewModel_HiltModule.bind(factory)
java.util.Map<java.lang.String,javax.inject.Provider<androidx.hilt.lifecycle.ViewModelAssistedFactory<? extends androidx.lifecycle.ViewModel>>> is injected at
androidx.hilt.lifecycle.ViewModelFactoryModules.ActivityModule.provideFactory(�, viewModelFactories)
@dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory java.util.Set<androidx.lifecycle.ViewModelProvider.Factory> is requested at
dagger.hilt.android.internal.lifecycle.DefaultViewModelFactories.ActivityEntryPoint.getActivityViewModelFactory() [com.example.barrechat192.BarreApp_HiltComponents.ApplicationC ? com.example.barrechat192.BarreApp_HiltComponents.ActivityRetainedC ? com.example.barrechat192.BarreApp_HiltComponents.ActivityC]
The following other entry points also depend on it:
dagger.hilt.android.internal.lifecycle.DefaultViewModelFactories.FragmentEntryPoint.getFragmentViewModelFactory() [com.example.barrechat192.BarreApp_HiltComponents.ApplicationC ? com.example.barrechat192.BarreApp_HiltComponents.ActivityRetainedC ? com.example.barrechat192.BarreApp_HiltComponents.ActivityC ? com.example.barrechat192.BarreApp_HiltComponents.FragmentC][WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC).
【问题讨论】:
-
您是否尝试过在构造函数中使用提供的确切类型:
@DefaultDispatcher private val defaultScope: CoroutineDispatcher? -
@AdrianK 是的,谢谢,成功了!我不敢相信我错过了......
标签: android kotlin-coroutines dagger dagger-hilt