Koin: NoBeanDefFoundException, Check your module definitions
I had the same problem, but in my case Koin was unable to resolve an implementation of interface. I had:
interface MessagesRepository {...}
class MessagesRepositoryImpl : MessagesRepository {...}
class GetMessagesUseCase(private val messagesRepository: MessagesRepository) {...}
And in Koin module I wrote:
single { MessagesRepositoryImpl() }
single { GetMessagesUseCase(get()) }
So Koin couldn't find an instance of MessagesRepository
to inject it into GetMessagesUseCase
. Specifying singleton's type explicitly resolved the issue (but maybe there is a better solution):
single<MessagesRepository> { MessagesRepositoryImpl() }
single { GetMessagesUseCase(get()) }
I found the issue and the mistake was the module instead of modules (or.koin.core.KoinApplication)
@Before
fun setUp() {
startKoin { module { single { EmailValidatorUtilImpl } } }
}
so, the solution and the correct version are:
startKoin { modules(loginUtilsModule) }
single { MessagesRepositoryImpl() as MessagesRepository }
Yamashiro Rion you can do this