reactormonk
05/22/2025, 10:12 AMVaibhav Jaiswal
05/23/2025, 3:45 PMSergio C.
05/24/2025, 4:09 PMEmilio Colindres
05/25/2025, 11:12 PMLeo N
05/27/2025, 10:06 AMScope 'org.koin.ktor.plugin.RequestScope@2016737454' is closed
Has anyone else encountered this?
Our library versions are:
kotlinx-ktor = "2.3.13"
koin = "3.5.3"
kotlin = "1.9.10"
mattinger
05/27/2025, 5:22 PMstartKoin
call. Just want to confirm i'm not missing anythingCleveland Shaw
05/28/2025, 11:08 AMKoin: 4.1.0-RC1
Koin Annotations: 2.0.1-RC1
Kotlin: 2.1.21
Compose Multiplatform: 1.8.1
KSP: 2.1.21-2.0.1
Here are the dependencies involved:
[libraries]
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-annotations = { module = "io.insert-koin:koin-annotations", version.ref = "koinAnnotations" }
koin-ksp-compiler = { module = "io.insert-koin:koin-ksp-compiler", version.ref = "koinAnnotations" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin" }
koin-compose-viewmodel = { module = "io.insert-koin:koin-compose-viewmodel", version.ref = "koin" }
This is my Gradle setup:
implementation(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
api(libs.koin.annotations)
I’m encountering an issue during build related to duplicate classes, and I believe it’s a conflict between koin-annotations and koin-core-annotations. Here’s the actual error message:
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class org.koin.core.annotation.InjectedParam found in modules koin-annotations-jvm-2.0.1-RC1.jar -> koin-annotations-jvm-2.0.1-RC1 (io.insert-koin:koin-annotations-jvm:2.0.1-RC1) and koin-core-annotations-jvm-4.1.0-RC1.jar -> koin-core-annotations-jvm-4.1.0-RC1 (io.insert-koin:koin-core-annotations-jvm:4.1.0-RC1)
Duplicate class org.koin.core.annotation.Provided found in modules koin-annotations-jvm-2.0.1-RC1.jar -> koin-annotations-jvm-2.0.1-RC1 (io.insert-koin:koin-annotations-jvm:2.0.1-RC1) and koin-core-annotations-jvm-4.1.0-RC1.jar -> koin-core-annotations-jvm-4.1.0-RC1 (io.insert-koin:koin-core-annotations-jvm:4.1.0-RC1)
It seems like there’s a conflict between koin-annotations and koin-core-annotations jars. Is there a recommended way to avoid this duplication? Should I be aligning versions differently or excluding one of the modules manually?
Any guidance on how to cleanly resolve this in a KMP setup would be greatly appreciated 🙏
Thanks again for all your great work on Koin!Jonathan
05/29/2025, 6:13 PMViewModel
to a Dialog? I would like to extra scanning logic to a dialog and have it automatically cancel any pending jobs (flow
collection) once the dialog is dismissed. Currently I'm remembering my viewmodel when my dialog is displayed and manually calling a "dismissed" function that cancels my pending job. It would be nice if there exist some facility in Koin that would allow me to scope my viewmodel to a Dialog and handle canceling the viewModelScope
once it is removed.CRamsan
05/30/2025, 2:56 AMViewModelDependencies
) that I want to scope to be a singleton
within a single Window of my application. I am not sure how to approach it, I have tried to use a rememberKoinModules(WindowModule)
on each window but the singleton is shared across both windows. I also tried to use KoinScope<String>(UUID.random().toString()) {...}
and put the rememberKoinModules(WindowModule)
inside the scope but the ViewModelDependencies
was still a singleton across both scopes. 🤔 I assume I am doing something wrong and I am not understanding something about the scoping API. Would someone have an idea for how to approach this problem?
internal val WindowModule = module {
single {
ViewModelDependencies()
}
viewModel {
WindowViewModel()
}
}
class WindowViewModel(
private val dependencies: ViewModelDependencies,
) : ViewModel() {...}
@Composable
fun WindowScreen(
viewModel: WindowViewModel= koinViewModel(),
) {...}
fun main() = application {
KoinApplication(
application = {
modules(...)
}
) {
Window(
onCloseRequest = ::exitApplication,
title = "Window 1",
) {
WindowScreen()
}
Window(
onCloseRequest = ::exitApplication,
title = "Window 2",
) {
WindowScreen()
}
}
}
Sergio C.
05/30/2025, 10:04 AMval homeViewmodelModule = module {
viewModel { (handle: SavedStateHandle) -> HomeViewmodel(handle, get()) }
}
class HomeViewmodel(
handle: SavedStateHandle,
private val datastore: DataStore<Preferences>,
) : ViewModel(), KoinComponent {
private var _newState: String by handle.saved(
key = "new_state",
init = { "original" }
)
I set the state to _newState = "new state" send the app to the background, kill process and when restarting the value is the originalMeet
06/04/2025, 5:15 AMTal Zion
06/04/2025, 8:26 AMclass AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
doInitKoin(config: nil)
FirebaseApp.configure()
return true
}
}
This is the common implementation
Modules.kt
expect val platformModule: Module
val commonModule = module {
singleOf(::RemoteFirebaseRepository).bind<FirebaseRepository>()
}
KoinHelper.kt
// Common App Definitions
fun appModule() = listOf(commonModule, platformModule)
fun initKoin(config: KoinAppDeclaration? = null) {
// Initialize Koin with the platform-specific module
startKoin {
config?.invoke(this)
modules(appModule())
}
}
Any help if highly appriciatedTim Winters
06/05/2025, 1:23 PMOlivier Patry
06/07/2025, 10:41 AMarnaud.giuliani
06/09/2025, 8:18 AMJohn O'Reilly
06/09/2025, 10:42 AMKoinApplicationPreview
in 4.1.....should something like following work? I'm getting render issue as soon as I add the `koinViewModel`but I could be missing something else perhaps
@Preview
@Composable
fun PreviewPlayerListView() {
KoinApplicationPreview(application = { modules(appModule, commonModule(false)) }) {
SomeComposable()
}
}
@Composable
fun SomeComposable() {
val playerListViewModel = koinViewModel<PlayerListViewModel>()
Text("hey there")
}
Jonathan
06/09/2025, 4:18 PMkoinViewModel<VM_TYPE>()
seems to scope it to the current NavHost route. What’s the recommended way to achieve this?arnaud.giuliani
06/10/2025, 1:15 PMRoberto Fernandez Montero
06/12/2025, 9:32 AM[ksp] --> Missing Definition for property 'settings : com.russhwolf.settings.Settings' in 'com.binshelve.data.local.UserRepository'. Fix your configuration: add definition annotation on the class.
arnaud.giuliani
06/13/2025, 4:56 PMarnaud.giuliani
06/13/2025, 4:56 PMarnaud.giuliani
06/13/2025, 4:56 PMarnaud.giuliani
06/13/2025, 4:57 PMJonathan
06/13/2025, 8:47 PM@OptIn(ExperimentalPagingApi::class)
This declaration needs opt-in. Its usage must be marked with ‘@androidx.paging.ExperimentalPagingApi’ or ‘@OptIn(androidx.paging.ExperimentalPagingApi::class)’Does Koin not support transitive Opt-in annotations? How are other people solving this issue?
dazza5000
06/16/2025, 7:34 PMsimon.vergauwen
06/25/2025, 8:46 AMonClose
work on Desktop besides manually calling koin.close()
from a ShutdownHook?Mario Andhika
06/26/2025, 8:03 AMFarhazul Mullick
06/26/2025, 10:47 AMex: startKoin{
module{
singe { ClassA(get()) }
}
}
Farhazul Mullick
06/27/2025, 9:23 AMkoin.waitAllStartJobs()
Tim Karagosian
06/28/2025, 9:01 PM