Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.koin.core.error.NoBeanDefFoundException #31

Open
YervandAleksanyan opened this issue Jul 24, 2019 · 4 comments
Open

org.koin.core.error.NoBeanDefFoundException #31

YervandAleksanyan opened this issue Jul 24, 2019 · 4 comments

Comments

@YervandAleksanyan
Copy link

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.

@Dartlexx
Copy link
Contributor

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.

@YervandAleksanyan
Copy link
Author

@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??

@Dartlexx
Copy link
Contributor

@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?

@Dartlexx
Copy link
Contributor

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(....))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants