eurycea
08/13/2021, 4:03 PMRoman Belousov
08/17/2021, 8:15 AMfactory { }
or single { }
methods because they are reified functions (got exception IllegalStateException: unsupported call of reified inlined function
). There is a task I created https://github.com/InsertKoinIO/koin/issues/1108 but still no answer.Yahor
08/17/2021, 8:17 AMwbertan
08/17/2021, 9:24 AMkoin.get(objCObject: type) *as*! T
in Swift and it works, we are calling it in SceneDelegate
willConnectTo
.
When opening the app, all works, putting the app in background, still works, coming back still works. After some time the app in Background, we can see a bunch of crashes in that line on SceneDelegate
trying to get
the dependency.
The object I’m trying to get in SceneDelegate
is the IsAuthenticatedUseCase
(hence I’m putting everything it needs to actually creates its own dependencies - in 🧵).
koin
is created and started in SceneDelegate
, or the error would be a nil
if it wasn’t.
Non-fatal Exception: InstanceCreationException
Could not create instance for [Singleton:'my.package.common.core.authentication.IsAuthenticatedUseCase']
Sorry for the stacktrace, we are using CrashKiOS to actually be able to see this crash, will post the stacktrace, and definition of dependencies in 🧵g4sarma
08/19/2021, 9:27 AMBradford Canonigo
08/28/2021, 7:40 AMstartKoin
inside my Application class in Android, and called loadKoinModules
inside the MainActivity after user logged in. Why am I always receiving KoinApplicaiton has not been started
error?kevindmoore
08/30/2021, 5:49 PMSongv
08/31/2021, 9:53 AMOrhan Tozan
09/02/2021, 2:24 PMMatt Thompson
09/02/2021, 3:47 PMcheckModules
with stateViewModel
? I was previously getting around it by using `
create<ViewModelType> { StateDefinitionParameter(SavedStateHandle()) }
but StateDefinitionParameter
no longer existsMatthew Laser
09/02/2021, 8:15 PMget
from KoinJavaComponent
, but not sure if that is the preferred method for getting on demand instances in Kotlin codemirland
09/17/2021, 3:21 PMorafaaraujo
09/22/2021, 1:48 PME/AndroidRuntime: FATAL EXCEPTION: main
Process: ......, PID: 29490
java.lang.StackOverflowError: stack size 8MB
at kotlin.reflect.jvm.internal.pcollections.IntTree.get(IntTree.java:93)
at kotlin.reflect.jvm.internal.pcollections.IntTree.get(IntTree.java:93)
at kotlin.reflect.jvm.internal.pcollections.IntTreePMap.get(IntTreePMap.java:42)
at kotlin.reflect.jvm.internal.pcollections.HashPMap.getEntries(HashPMap.java:85)
at kotlin.reflect.jvm.internal.pcollections.HashPMap.get(HashPMap.java:51)
at kotlin.reflect.jvm.internal.KClassCacheKt.getOrCreateKotlinClass(kClassCache.kt:32)
at kotlin.reflect.jvm.internal.ReflectionFactoryImpl.getOrCreateKotlinClass(ReflectionFactoryImpl.java:50)
at kotlin.jvm.internal.Reflection.getOrCreateKotlinClass(Reflection.java:59)
at org.koin.android.ext.koin.ModuleExtKt.androidApplication(ModuleExt.kt:54)
chi
09/27/2021, 10:01 AMclass Cache(sess: SessionManager)
class MyViewModel(cache: Cache): ViewModel {}
module {
single { SessionManager() }
scope(named("userSession")) {
scoped { Cache(get()) }
viewModel { MyViewModel(get()) }
}
}
class MyFragment: Fragment() {
private val myVm: MyViewModel by viewModel()
}
The above is the structure of my koin setup but when I run this it crashes my app with the error;
Caused by: org.koin.core.error.NoBeanDefFoundException: No definition found for class:'com.play.MyViewModel'. Check your definitions!
Please what could I be doing wrongly here?George Theocharis
09/28/2021, 8:29 AMVivek Modi
09/28/2021, 11:34 AMkoin 2.2.2
whenerver i used any object class and inject through koin and used that object class in any other class like view holder it gives warning. How to avoid this warningScott Kruse
10/15/2021, 4:29 AMSam
10/19/2021, 3:56 AMKoin
Ref: https://proandroiddev.com/how-dagger-hilt-and-koin-differ-under-the-hood-c3be1a2959d7
Im curious, How can I calculate the performance of Koin in Runtime like this articles?
Thanks.Merseyside
10/21/2021, 8:51 AMChris
10/25/2021, 8:54 AMval viewModel by getScope("user-session").viewModel<Class>(owner = this)
this works fine at least for koin 2.x. What happens in getscope() is it check it this scope is there or creates a new one of user-session. So that the viewmodel is bound to the user-session scope.
For koin 3.x I have to add more complex implementation
val viewModel by getScope("user-session").viewModel<Class>(owner = {ViewModelOwner.from(findNavController().getViewModelStoreOwner(R.id.graph))})
is this the way to go or is there a better solution for ? Thanks in advanceMatthew Laser
10/26/2021, 2:24 PMJobService
? It's an extension of Service
so it seems like Koin should support it in the way that Activity
and Fragment
are (by being able to simply use by inject<MyClass>()
) but it's not working as I'd expectABRAR WIRYAWAN
10/31/2021, 2:43 PMarnaud.giuliani
11/02/2021, 10:30 AMEric Martori
11/02/2021, 1:20 PMCaused by java.util.NoSuchElementException
ArrayDeque is empty.
org.koin.core.scope.Scope.resolveInstance (Scope.kt:213)
org.koin.core.scope.Scope.get (Scope.kt:193)
org.koin.androidx.viewmodel.factory.DefaultViewModelFactory.create (DefaultViewModelFactory.kt:11)
androidx.lifecycle.ViewModelProvider.get (ViewModelProvider.java:187)
androidx.lifecycle.ViewModelProvider.get (ViewModelProvider.java:150)
org.koin.androidx.viewmodel.ViewModelResolverKt.get (ViewModelResolver.kt:23)
org.koin.androidx.viewmodel.ViewModelResolverKt.resolveInstance (ViewModelResolver.kt:12)
org.koin.androidx.viewmodel.scope.ScopeExtKt.getViewModel (ScopeExt.kt:86)
org.koin.androidx.viewmodel.scope.ScopeExtKt.getViewModel (ScopeExt.kt:72)
org.koin.androidx.viewmodel.ext.android.ViewModelStoreOwnerExtKt.getViewModel (ViewModelStoreOwnerExt.kt:68)
But we are unable to reproduce the issue and haven't seen it in over 2 weeks of testing.
I've seen that there is an open issue that seems related to this: https://github.com/InsertKoinIO/koin/issues/1149
But we are no using the getOrNull
method that the tickets seems to imply is the cause of the issue.
Is there anything (besides downgrading or waiting for a fix) that we can do? Does anyone know a way we could try and reproduce the issue in a consistent manner or why is it so hard to reproduce the issue?aipok
11/03/2021, 9:44 AMfactory
is getting warning This API is using reflection and implies some introspection performance penalties on limited capacity devices (Android)
in 3.1.3? How to fix it?holgerbrandl
11/06/2021, 7:19 PMRak
11/08/2021, 3:38 PMdeclare
method but I cant seem to get it to resolve in the IDE.Lukasz Kalnik
11/09/2021, 5:07 PMshared
:
CommonModule.kt:
val commonModule = module {
single<HttpClient> { TmdbApi.createHttpClient() }
single<TmdbApi> { TmdbApi(client = get()) }
}
fun initKoin() = startKoin {
modules(CommonModule.module)
}
In the Android app I can inject dependencies very easily:
val tmdbApi: TmdbApi by inject()
In the iOS AppDelegate I call CommonModuleKt.doInitKoin()
How can I inject the dependencies in the iOS ContentView
?Hakob Astvacatryan
11/10/2021, 3:39 PMAlexander Mitropolsky
11/11/2021, 5:00 PMscope(qualifier<SomeFragment>())
scope(qualifier<LongLiveScope>()) {
viewModel { SomeViewModel ()}
}
Then we link these scopes:
fragmentScope.linkTo(longLiveScope)
Then we inject SomeViewModel into SomeFragment with the viewModel()
extension, which uses the ViewModelStore from SomeFragment.
When SomeFragment is destroyed, its ViewModelStore is also destroyed, and SomeViewModel::onClear
will be called.
However, the SomeViewModel instance will not be destroyed because it is scoped in LongLiveScope, which leads to issues when the same (already cleared) instance of SomeViewModel is reused in new fragments. For example, ViewModel’s coroutines scope will not work because it will be already closed after onCleared.
I think the ViewModel should be shared using the shared ViewModelStore, but not using the Koin scope, otherwise, it breaks the lifecycle of the ViewModel itself.
I hope I explained this issue in sufficient detail.
Can you please explain why the ViewModel definition has changed?
And what can I do if the ViewModelStoreOwner is different from the scope, other than rolling back the old ViewModel definition?
Thank you!Alexander Mitropolsky
11/11/2021, 5:00 PMscope(qualifier<SomeFragment>())
scope(qualifier<LongLiveScope>()) {
viewModel { SomeViewModel ()}
}
Then we link these scopes:
fragmentScope.linkTo(longLiveScope)
Then we inject SomeViewModel into SomeFragment with the viewModel()
extension, which uses the ViewModelStore from SomeFragment.
When SomeFragment is destroyed, its ViewModelStore is also destroyed, and SomeViewModel::onClear
will be called.
However, the SomeViewModel instance will not be destroyed because it is scoped in LongLiveScope, which leads to issues when the same (already cleared) instance of SomeViewModel is reused in new fragments. For example, ViewModel’s coroutines scope will not work because it will be already closed after onCleared.
I think the ViewModel should be shared using the shared ViewModelStore, but not using the Koin scope, otherwise, it breaks the lifecycle of the ViewModel itself.
I hope I explained this issue in sufficient detail.
Can you please explain why the ViewModel definition has changed?
And what can I do if the ViewModelStoreOwner is different from the scope, other than rolling back the old ViewModel definition?
Thank you!arnaud.giuliani
11/12/2021, 8:17 AM