In my android application am using MVVM architecture and using koin library for DI. Below is my Repository class:
class JaiminRepository constructor(
private var remoteDataSource : RemoteDataSource,
private var enrollApiInterface : EnrollApiInterface
) {
...
}
Created module for is as below:
val jaiminRepositoryModule = module {
single {
JaiminRepository(get(),get())
}
}
For this I am getting error as :
Instance creation error : could not create instance for [Singleton:'com.jaimin.sdk.repository.JaiminRepository']: org.koin.core.error.NoBeanDefFoundException: |- No definition found for class:'com.jaimin.api.RemoteDataSource'. Check your definitions! org.koin.core.scope.Scope.throwDefinitionNotFound(Scope.kt:287) org.koin.core.scope.Scope.resolveValue(Scope.kt:257)
So I have added factory for RemoteDataSource.
factory {
RemoteDataSource()
}
and finally it look like as below:
val jaiminRepositoryModule = module {
factory {
RemoteDataSource()
}
single {
JaiminRepository(get(),get())
}
}
But still am getting error. What might be the issue? Do I need to do something with EnrollApiInterface also? Please guide. Thanks in Advance.