https://kotlinlang.org logo
#compose
Title
# compose
a

Adrian Witaszak

11/19/2023, 6:32 PM
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

Chrimaeon

11/19/2023, 6:48 PM
Despite the import issue you are facing - it’s a very bad idea to pass keys to side-effects like you do 😅
a

Adrian Witaszak

11/19/2023, 6:49 PM
The issue is not with the Launch effect but in the whole module all kotlin std lib references are unresolved
c

Chrimaeon

11/19/2023, 6:51 PM
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

Adrian Witaszak

11/19/2023, 6:53 PM
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

Chrimaeon

11/19/2023, 6:54 PM
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

Adrian Witaszak

11/19/2023, 6:55 PM
is your suggestion to pass those two keys separately?
c

Chrimaeon

11/19/2023, 6:55 PM
yes, definitely.
a

Adrian Witaszak

11/19/2023, 6:55 PM
Copy code
LaunchedEffect(filterModal, getPremiumModal) {...}
c

Chrimaeon

11/19/2023, 6:55 PM
👍🏻
a

Adrian Witaszak

11/19/2023, 6:56 PM
Just not sure what difference it makes? Or is it just using the list as a key not recommended?
c

Chrimaeon

11/19/2023, 6:58 PM
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

Adrian Witaszak

11/19/2023, 6:59 PM
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

Chrimaeon

11/20/2023, 8:45 AM
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

Adrian Witaszak

11/20/2023, 8:54 AM
If by targets you mean Android targets or java target, then i use convention plugins for shared gradle configuration in multiplatform modules
c

Chrimaeon

11/20/2023, 8:57 AM
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

Adrian Witaszak

11/20/2023, 8:57 AM
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

Chrimaeon

11/20/2023, 9:00 AM
Yeah, looks fine if that is applied to all of the included ones.
a

Adrian Witaszak

11/20/2023, 9:39 AM
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

Chrimaeon

11/20/2023, 9:42 AM
👍