i've got an issue with unresolved Kotlin STD lib d...
# compose
a
i've got an issue with unresolved Kotlin STD lib dependencies. I only see it in the module with Compose Multiplatform common ui. Other modules seem fine. I already deleted
.gradle
,
.m2
,
.konan
deleted all ide and downloaded them again, invalidated cache, repaired the ide, cleaned mac with clean my mac, and it still happened... Has anyone had this issue? I don't know what else I can do. Nothing changed in the build settings in the last 2 weeks. The issue appeared yesterday. The Android project runs fine. Issue reproduced in AS Canary, AS stable, IJ Canary, IJ stable, Fleet so i don't think this is an IDE issue. Kotlin 1.9.20 compose 1.5.10
c
Despite the import issue you are facing - it’s a very bad idea to pass keys to side-effects like you do 😅
a
The issue is not with the Launch effect but in the whole module all kotlin std lib references are unresolved
c
sure. I did not try to resolve your issue. I just wanted to point out, that you should not pass the key to the
LaunchedEffect
like this.
a
Why not? the filterModal is a selected enum and getPremiumModal is a simple object with id and boolean
i passed them as a list so launch effect can react if any of them changes
c
but on every re-composition the list is recreated, resulting in a new “key” and your effect is run again.
LaunchedEffect
has multiple overrides to pass multiple keys.
a
is your suggestion to pass those two keys separately?
c
yes, definitely.
a
Copy code
LaunchedEffect(filterModal, getPremiumModal) {...}
c
👍🏻
a
Just not sure what difference it makes? Or is it just using the list as a key not recommended?
c
so now, if one if the 2 changes, the effect is run. with a list, it will run on every composition because you create a new list which is then a new key which triggers the effect to run.
a
Alright i get it now. Thanks 🙂
Back to the issue. What i noticed is that I get this issue every time I apply any module dependency to the module with Compose, which is a mystery for me... I have a KMP modular project. Two app modules for Android and iOS, one Compose UI module, ten feature modules with business logic for UI, and one data module for Apollo networking. The issue disappears when I remove features and data dependencies from the Compose UI module, but then ofc everything else does not compile because of unresolved local dependencies. Last night I did a test and I moved code from all modules into the Compose UI module and now all Kotlin STD lib is resolved and runs fine, but it is not an ideal approach to have a big mono-repo...
c
And it’s a Multiplattform compose module? Get sure that all „imported“ modules are the Multiplattform modules as well.
Especially have the same targets applied.
a
If by targets you mean Android targets or java target, then i use convention plugins for shared gradle configuration in multiplatform modules
c
With targets I mean https://kotlinlang.org/docs/multiplatform-set-up-targets.html You need to have the same configuration in all dependent modules.
a
here is my shared configuration:
Copy code
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    id("com.android.library")
}

group = ProjectConfig.packageName + "." + project.name

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
@Suppress("unused")
kotlin {
    applyDefaultHierarchyTemplate()
    jvmToolchain(ProjectConfig.Kotlin.jvmTargetInt)

    androidTarget()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    targets.withType<KotlinNativeTarget> {
        binaries.all {
            freeCompilerArgs += listOf("-Xexpect-actual-classes")
        }
    }
}

android {
    namespace = group.toString()
    compileSdk = ProjectConfig.Android.compileSdk
    defaultConfig {
        minSdk = ProjectConfig.Android.minSdk
    }
    compileOptions {
        sourceCompatibility = ProjectConfig.Kotlin.javaVersion
        targetCompatibility = ProjectConfig.Kotlin.javaVersion
    }
}
which is pretty default
c
Yeah, looks fine if that is applied to all of the included ones.
a
Solved the issue. Downgrading Apollo Kotlin fixed it all. I will create a new issue for it in the Apollo repo.
Thanks for the help @Chrimaeon
c
👍