Title
e

Emirhan Emmez

11/30/2021, 12:32 PM
Caused by: org.koin.core.error.NoBeanDefFoundException: |- No definition found for class:'com.emirhan.controller.UserDataSourceImp'. Check your definitions!
single<UserDataSource> { UserDataSourceImp() }
single { UserController(get()) }
Is anyone get this error about koin di?
n

Nikky

11/30/2021, 12:33 PM
i am going to guess that the constructor of
UserController
needs a
UserDataSourceImp
and not a
UserDataSource
try
single { UserController(get<UserDataSource>()) }
just to figure out if thats the issue
👏 1
e

Emirhan Emmez

11/30/2021, 12:40 PM
but constructor parameter of UserController is UserDataSourceImp
you can check
n

Nikky

11/30/2021, 1:05 PM
and with the line
single<UserDataSource> { UserDataSourceImp() }
you tell koin to "store" the
Imp
as the interface, so when it looks for the specific class.. it fails
change it to
class UserController(private val userDataSource: UserDataSource)
and it will start working.. and you can use whatever implementation satisfies the interface
UserDataSource
e

Emirhan Emmez

11/30/2021, 1:26 PM
i assume i solved it because it throws another exception: java.lang.NoSuchMethodError: 'double kotlin.time.Duration.toDouble-impl(long, java.util.concurrent.TimeUnit)'
in
single { UserController(get()) }
line
OK i saw there is a open issue about koin does not support kotlin 1.6.0 in #koin
i downgrade to 1.5.31 and its solved 🙂 thx for your help