Closed Shabinder closed 3 years ago
@Shabinder Could you please also provide build.gradle
of the shared module and of the desktop app module?
Desktop Build Gradle:
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}
group = "com.shabinder"
version = Versions.versionName
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
sourceSets {
val jvmMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation(project(":common:database"))
implementation(project(":common:dependency-injection"))
implementation(project(":common:compose-ui"))
implementation(Decompose.decompose)
implementation(Decompose.extensionsCompose)
implementation(MVIKotlin.mvikotlin)
implementation(MVIKotlin.mvikotlinMain)
}
}
val jvmTest by getting
}
}
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "SpotiFlyer"
}
}
}
Common Module:
import org.jetbrains.compose.compose
plugins {
id("multiplatform-compose-setup")
id("android-setup")
id("kotlin-parcelize")
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation(compose.materialIconsExtended)
//implementation("org.jetbrains.compose.material:material-icons-extended:0.3.0-build150")
implementation(project(":common:dependency-injection"))
//implementation("com.alialbaali.kamel:kamel-image:0.0.7")
implementation(project(":common:data-models"))
implementation(project(":common:database"))
implementation(SqlDelight.coroutineExtensions)
implementation(MVIKotlin.coroutines)
implementation(MVIKotlin.mvikotlin)
implementation(Decompose.decompose)
implementation(Decompose.extensionsCompose)
//Coil-Image Loading
Versions.coilVersion.let{
implementation("dev.chrisbanes.accompanist:accompanist-coil:$it")
implementation("dev.chrisbanes.accompanist:accompanist-insets:$it")
}
}
}
}
}
It is a very weird crash. Am I right that the crash in on Desktop only? For some reason it uses Dispatchers.Main
for Android. It is hard to get more details without a reproducer. Would you be able to provide it?
Yup , its desktop only, what do you mean by reproducer
@Shabinder By reproducer I mean a project that I could debug.
@arkivanov I have invited you as a collaborator ,so that you may have access to private repo's Project , which might help you in debugging.
@Shabinder Thanks for the reproducer! So the is issue is because you added accompanist
libraries to the commonMain
source set. These libraries are Android only, they can't be used in common code.
oops.., Thanks @arkivanov removing accompanist libs did the trick. I forgot to remove them while I was experimenting.
Caused by: java.lang.NoClassDefFoundError: android/os/Looper at kotlinx.coroutines.android.AndroidDispatcherFactory.createDispatcher(HandlerDispatcher.kt:55) at kotlinx.coroutines.android.AndroidDispatcherFactory.createDispatcher(HandlerDispatcher.kt:52) at kotlinx.coroutines.internal.MainDispatchersKt.tryCreateDispatcher(MainDispatchers.kt:57) at kotlinx.coroutines.internal.MainDispatcherLoader.loadMainDispatcher(MainDispatchers.kt:38) at kotlinx.coroutines.internal.MainDispatcherLoader.(MainDispatchers.kt:22) at kotlinx.coroutines.Dispatchers.getMain(Dispatchers.kt:58) at com.arkivanov.mvikotlin.extensions.coroutines.SuspendExecutor.(SuspendExecutor.kt:23) at com.shabinder.common.main.store.SpotiFlyerMainStoreProvider$ExecutorImpl.(SpotiFlyerMainStoreProvider.kt:57) at com.shabinder.common.main.store.SpotiFlyerMainStoreProvider$provide$1$1.invoke(SpotiFlyerMainStoreProvider.kt) at com.shabinder.common.main.store.SpotiFlyerMainStoreProvider$provide$1$1.invoke(SpotiFlyerMainStoreProvider.kt) at com.arkivanov.mvikotlin.main.store.DefaultStore.(DefaultStore.kt:31) ... 143 more
My Store Creator:
My Suspend Executor:
All methods like openPlatform,etc are just expect/actual empty blocks
PS: 1.All Implementations Are very similar to as shown in todo app , except these are coroutine/suspend instead of Reaktive 2.Crash is in Desktop only , same implementation works good in Android app(All Code is Common/Shared module)