I'm having a really hard time figuring out why I g...
# koin
k
I'm having a really hard time figuring out why I get a crash getting a view model. It works the first time but not the 2nd. I am using KoinApplication and not startKoin (as this is a library)
This is Koin 2.2.2
t
Why does it crash? Do you have a stacktrace you could share?
k
Copy code
Caused by: org.koin.core.error.NoBeanDefFoundException: No definition found for class:'com.intuit.payments.billpay.paymentscard.PaymentsCardViewModel'. Check your definitions!
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.core.scope.Scope.throwDefinitionNotFound(Scope.kt:282)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.core.scope.Scope.resolveInstance(Scope.kt:251)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.core.scope.Scope.get(Scope.kt:204)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.androidx.viewmodel.factory.DefaultViewModelFactory.create(DefaultViewModelFactory.kt:11)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:187)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.androidx.viewmodel.ViewModelResolverKt.get(ViewModelResolver.kt:23)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.androidx.viewmodel.ViewModelResolverKt.resolveInstance(ViewModelResolver.kt:12)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.androidx.viewmodel.scope.ScopeExtKt.getViewModel(ScopeExt.kt:86)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.androidx.viewmodel.scope.ScopeExtKt.getViewModel(ScopeExt.kt:72)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.androidx.viewmodel.koin.KoinExtKt.getViewModel(KoinExt.kt:41)
07-02 11:44:09.209 15053 15053 E AndroidRuntime: 	at org.koin.androidx.viewmodel.ext.android.FragmentExtKt.getViewModel(FragmentExt.kt:71)
I put in lots of debug statements and I see that Koin is getting re-initialized. I don't see any singletons in the KoinApplication that would cause a problems
Could it be the FragmentManager?
Ok. I think I found the problem. Our app was creating multiple instances of my fragment