10

Not sure why this is failing build. Everything seems to be in check

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

The error I am getting is this, but it looks like I am providing everything correctly, the qualifiers and the injections to the repository class, it's very strange...

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).

chrisdottel
  • 1,053
  • 1
  • 12
  • 21

1 Answers1

6

I just tested this and the problem lies in this line here:

@DefaultDispatcher private val defaultScope: CoroutineContext

replace CoroutineContext type with CoroutineDispatcher and it will work as intended.

Vitaliy-T
  • 733
  • 6
  • 23