Caused by: org.koin.core.error.NoBeanDefFoundExcep...
# ktor
e
Caused by: org.koin.core.error.NoBeanDefFoundException: |- No definition found for class:'com.emirhan.controller.UserDataSourceImp'. Check your definitions!
Copy code
single<UserDataSource> { UserDataSourceImp() }
single { UserController(get()) }
Is anyone get this error about koin di?
n
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
but constructor parameter of UserController is UserDataSourceImp
UserController.kt,UserDataSource.kt,UserDataSourceImp.kt
you can check
n
and with the line
Copy code
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
Copy code
class UserController(private val userDataSource: UserDataSource)
and it will start working.. and you can use whatever implementation satisfies the interface
UserDataSource
e
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
Copy code
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
1459 Views