org.koin.core.error.NoBeanDefFoundException
Hi I used this library, and I have runtime exception with this stack trace
Caused by: org.koin.core.error.NoBeanDefFoundException: Found multiple definitions for type 'com.epam.coroutinecache.core.Persistence': [[type:Single,name:'DiskCache', primary_type:'com.epam.coroutinecache.core.DiskCache', secondary_type:com.epam.coroutinecache.core.Persistence], [type:Single,name:'DiskCache', primary_type:'com.epam.coroutinecache.core.DiskCache', secondary_type:com.epam.coroutinecache.core.Persistence]]. Please use the 'bind<P,S>()' function to bind your instance from primary and secondary types.
at org.koin.core.registry.BeanRegistry.findDefinitionBySecondaryType(BeanRegistry.kt:237)
at org.koin.core.registry.BeanRegistry.findDefinition(BeanRegistry.kt:223)
at org.koin.core.scope.Scope.findDefinition(Scope.kt:169)
at org.koin.core.scope.Scope.resolveInstance(Scope.kt:164)
at org.koin.core.scope.Scope.get(Scope.kt:128)
at com.epam.coroutinecache.internal.ProxyProvider.<init>(ProxyProvider.kt:51)
at com.epam.coroutinecache.api.CoroutinesCache.using(CoroutinesCache.kt:33)
at services.CacheService.<init>(CacheService.kt:27)
at services.CacheService_Factory.get(CacheService_Factory.java:22)
at services.CacheService_Factory.get(CacheService_Factory.java:9)
at com.tickster.boxpoint.di.modules.ServicesModule_ProvideCacheServiceFactory.get(ServicesModule_ProvideCacheServiceFactory.java:23)
at com.tickster.boxpoint.di.modules.ServicesModule_ProvideCacheServiceFactory.get(ServicesModule_ProvideCacheServiceFactory.java:10)
at com.tickster.boxpoint.core.services.implementation.BoxpointApiService_Factory.get(BoxpointApiService_Factory.java:41)
at com.tickster.boxpoint.core.services.implementation.BoxpointApiService_Factory.get(BoxpointApiService_Factory.java:11)
at com.tickster.boxpoint.core.di.CoreServicesModule_ProvideIBoxpointApiServiceFactory.get(CoreServicesModule_ProvideIBoxpointApiServiceFactory.java:28)
2019-07-24 18:01:14.671 22287-22287/com.xamlab.boxpoint E/AndroidRuntime: at com.tickster.boxpoint.core.di.CoreServicesModule_ProvideIBoxpointApiServiceFactory.get(CoreServicesModule_ProvideIBoxpointApiServiceFactory.java:10)
at com.tickster.boxpoint.viewmodels.configuration.arena.implementation.ArenaViewModel_Factory.get(ArenaViewModel_Factory.java:34)
at com.tickster.boxpoint.viewmodels.configuration.arena.implementation.ArenaViewModel_Factory.get(ArenaViewModel_Factory.java:11)
at com.tickster.boxpoint.viewmodels.di.factories.ViewModelFactory.create(ViewModelFactory.kt:28)
Thanks for attention.
Hi Yervand. Thanks for reaching out. What versions of Koin and CoroutineCache are you using?
Recently, Koin version inside CoroutineCache was updated to 2.0.1 - most probably that is the reason of your troubles.
@Dartlexx hi thanks for the response, I using Koin version 2.0.1 CoroutineCache 0.9.4 I have the multi-module app, can that dependent with this exception??
@yauheni-parakhnevich It definitely seems to be an issue with Koin setup - whether in this library or in your project. Can you tell me please, how many instances of CoroutineCache object exist in your app at any point of time?
I was able to reproduce this issue by declaring CoroutineCache provider as factory, instead of single. Please, try to replace:
factory {
CoroutinesCache(CacheParams(....))
}
with:
single {
CoroutinesCache(CacheParams(....))
}