AlexGladkov / Odyssey

Odyssey it's a declarative multiplatform navigation library for Multiplatform Compose
https://youtube.com/c/MobileDeveloper
MIT License
255 stars 21 forks source link

DESKTOP "Module with the Main dispatcher had failed to initialize" when runReleaseDistributable #91

Closed nevrozza closed 1 year ago

nevrozza commented 1 year ago

Приложение(Windows) вылетает при попытке перейти на экран (screen()) . Добавление зависимости swing coroutines в desktopMain не помогает.


Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize
    at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.missing(MainDispatchers.kt:118)
    at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.isDispatchNeeded(MainDispatchers.kt:96)
    at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:319)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default$6a2188af(Cancellable.kt:25)
    at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:2110)
    at kotlinx.coroutines.CancellableContinuation$DefaultImpls.launch(CancellableContinuation.kt:3056)
    at kotlinx.coroutines.CancellableContinuation$DefaultImpls.launch$default(CancellableContinuation.kt:4047)
    at kotlinx.coroutines.flow.FlowKt.launchIn(Unknown Source)
    at ru.alexgladkov.odyssey.core.extensions.CFlow.watch(CFlow.kt:19)
    at ru.alexgladkov.odyssey.compose.navigation.modal_navigation.ModalNavigatorKt$ModalNavigator$2.invokeSuspend(ModalNavigator.kt:55)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at androidx.compose.ui.platform.FlushCoroutineDispatcher$dispatch$2$1.invoke(FlushCoroutineDispatcher.skiko.kt:1056)
    at androidx.compose.ui.platform.FlushCoroutineDispatcher.performRun(FlushCoroutineDispatcher.skiko.kt:85)
    at androidx.compose.ui.platform.FlushCoroutineDispatcher.access$performRun(FlushCoroutineDispatcher.skiko.kt:33)
    at androidx.compose.ui.platform.FlushCoroutineDispatcher$dispatch$2.invokeSuspend(FlushCoroutineDispatcher.skiko.kt:51)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3d695df6, Dispatchers.Main[missing, cause=java.util.ServiceConfigurationError: kotlinx.coroutines.internal.MainDispatcherFactory: Provider kotlinx.coroutines.swing.SwingDispatcherFactory not found]]
Caused by: java.util.ServiceConfigurationError: kotlinx.coroutines.internal.MainDispatcherFactory: Provider kotlinx.coroutines.swing.SwingDispatcherFactory not found
    at java.base/java.util.ServiceLoader.fail(Unknown Source)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(Unknown Source)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(Unknown Source)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(Unknown Source)
    at java.base/java.util.ServiceLoader$2.hasNext(Unknown Source)
    at java.base/java.util.ServiceLoader$3.hasNext(Unknown Source)
    at kotlin.collections.CollectionsKt___CollectionsKt.toCollection(_Collections.kt:1295)
    at kotlin.collections.CollectionsKt___CollectionsKt.toMutableList(_Collections.kt:1328)
Caused by: java.util.ServiceConfigurationError: kotlinx.coroutines.internal.MainDispatcherFactory: Provider kotlinx.coroutines.swing.SwingDispatcherFactory not found

    at kotlin.collections.CollectionsKt___CollectionsKt.toList(_Collections.kt:1319)
    at kotlinx.coroutines.internal.FastServiceLoader.load(FastServiceLoader.kt:90)
    at kotlinx.coroutines.internal.FastServiceLoader.loadMainDispatcherFactory$kotlinx_coroutines_core(FastServiceLoader.kt:55)
    at kotlinx.coroutines.internal.MainDispatcherLoader.loadMainDispatcher(MainDispatchers.kt:27)
    at kotlinx.coroutines.internal.MainDispatcherLoader.<clinit>(MainDispatchers.kt:22)
    at kotlinx.coroutines.Dispatchers.getMain(Dispatchers.kt:57)
    ... 23 more
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize
    at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.missing(MainDispatchers.kt:118)
    at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.isDispatchNeeded(MainDispatchers.kt:96)
    at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:319)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default$6a2188af(Cancellable.kt:25)
    at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:2110)
    at kotlinx.coroutines.CancellableContinuation$DefaultImpls.launch(CancellableContinuation.kt:3056)
    at kotlinx.coroutines.CancellableContinuation$DefaultImpls.launch$default(CancellableContinuation.kt:4047)
    at kotlinx.coroutines.flow.FlowKt.launchIn(Unknown Source)
    at ru.alexgladkov.odyssey.core.extensions.CFlow.watch(CFlow.kt:19)
    at ru.alexgladkov.odyssey.compose.navigation.modal_navigation.ModalNavigatorKt$ModalNavigator$2.invokeSuspend(ModalNavigator.kt:55)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at androidx.compose.ui.platform.FlushCoroutineDispatcher$dispatch$2$1.invoke(FlushCoroutineDispatcher.skiko.kt:1056)
    at androidx.compose.ui.platform.FlushCoroutineDispatcher.performRun(FlushCoroutineDispatcher.skiko.kt:85)
    at androidx.compose.ui.platform.FlushCoroutineDispatcher.access$performRun(FlushCoroutineDispatcher.skiko.kt:33)
    at androidx.compose.ui.platform.FlushCoroutineDispatcher$dispatch$2.invokeSuspend(FlushCoroutineDispatcher.skiko.kt:51)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelled}@3d695df6, Dispatchers.Main[missing, cause=java.util.ServiceConfigurationError: kotlinx.coroutines.internal.MainDispatcherFactory: Provider kotlinx.coroutines.swing.SwingDispatcherFactory not found]]
    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.ui.awt.ComposeLayer$coroutineExceptionHandler$1@1fb1beab, androidx.compose.runtime.BroadcastFrameClock@4e5d5721, StandaloneCoroutine{Cancelling}@27fff5a4, FlushCoroutineDispatcher@7eacf369]
Caused by: java.util.ServiceConfigurationError: kotlinx.coroutines.internal.MainDispatcherFactory: Provider kotlinx.coroutines.swing.SwingDispatcherFactory not found
    at java.base/java.util.ServiceLoader.fail(Unknown Source)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(Unknown Source)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(Unknown Source)
    at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(Unknown Source)
    at java.base/java.util.ServiceLoader$2.hasNext(Unknown Source)
    at java.base/java.util.ServiceLoader$3.hasNext(Unknown Source)
    at kotlin.collections.CollectionsKt___CollectionsKt.toCollection(_Collections.kt:1295)
    at kotlin.collections.CollectionsKt___CollectionsKt.toMutableList(_Collections.kt:1328)
    at kotlin.collections.CollectionsKt___CollectionsKt.toList(_Collections.kt:1319)
    at kotlinx.coroutines.internal.FastServiceLoader.load(FastServiceLoader.kt:90)
    at kotlinx.coroutines.internal.FastServiceLoader.loadMainDispatcherFactory$kotlinx_coroutines_core(FastServiceLoader.kt:55)
    at kotlinx.coroutines.internal.MainDispatcherLoader.loadMainDispatcher(MainDispatchers.kt:27)
    at kotlinx.coroutines.internal.MainDispatcherLoader.<clinit>(MainDispatchers.kt:22)
    at kotlinx.coroutines.Dispatchers.getMain(Dispatchers.kt:57)
    ... 23 more```
nevrozza commented 1 year ago

Fixed. ProGuard removed kotlinx.coroutines.swing.SwingDispatcherFactory

Fix: add "-keep class kotlinx.coroutines.swing.SwingDispatcherFactory" to ProGuard rules