Код: Выделить всё
@HiltViewModel
class MainViewModel @Inject constructor(
private val repository: UserRepository
) : ViewModel() {
}
Код: Выделить всё
interface UserRepository {
suspend fun loginUser(username: String, password: String): Pair
}
Код: Выделить всё
internal class UserDataSource @Inject constructor(private val octaveApi: OctaveApi) :
UserRepository {
override suspend fun loginUser(username: String, password: String): Pair {
return Pair(false, "unsucess")
}
}
Код: Выделить всё
@Module
@InstallIn(SingletonComponent::class)
abstract class ApiModule {
@Module
@InstallIn(SingletonComponent::class)
object Providers {
@Provides
@Singleton
internal fun provideOctaveApi(retrofit: Retrofit): OctaveApi =
retrofit.create(OctaveApi::class.java)
}
}
@Module
@InstallIn(ActivityRetainedComponent::class)
abstract class RetainedDataModule {
@Binds
internal abstract fun bindUserRepository(userDataSource: UserDataSource): UserRepository
}
Код: Выделить всё
/OctaveDashboard/app/build/generated/source/kapt/stagingExternalDebug/com/octave/OctaveApplication_HiltComponents.java:125: error: [Dagger/MissingBinding] com.octave.data.user.UserRepository cannot be provided without an @Provides-annotated method.
public abstract static class SingletonC implements OctaveApplication_GeneratedInjector,
^
com.octave.data.user.UserRepository is injected at
com.octave.MainViewModel(cornersRepository)
com.octave.MainViewModel is injected at
com.octave.MainViewModel_HiltModules.BindsModule.binds(vm)
@dagger.hilt.android.internal.lifecycle.HiltViewModelMap java.util.Map is requested at
dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.ViewModelFactoriesEntryPoint.getHiltViewModelMap() [com.octave.OctaveApplication_HiltComponents.SingletonC → com.octave.OctaveApplication_HiltComponents.ActivityRetainedC → com.octave.OctaveApplication_HiltComponents.ViewModelC]
Подробнее здесь: https://stackoverflow.com/questions/696 ... ted-method
Мобильная версия