https://kotlinlang.org logo
a

Adam Brown

08/30/2022, 10:55 PM
This is really strange, I have a
composeUi
module, and
commonMain
includes the multiplatform compose artifacts. And I'm able to write desktop specific compose code inside my
desktopMain
JVM source set, but then when I try to write some Android specific compose in the
androidMain
source set, it doesn't know about the compose dependencies at all. Has anyone else run into this?
Copy code
sourceSets {
        val commonMain by getting {
            //@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
            dependencies {
                api(project(":common"))
                api(compose.runtime)
                api(compose.uiTooling)
                api(compose.preview)
                api(compose.foundation)
                api(compose.material)
                //api(compose.material3)
                api(compose.animation)
                api(compose.animationGraphics)
                api(compose.materialIconsExtended)
                api("org.jetbrains.compose.ui:ui-util:$compose_version")
                api("org.jetbrains.compose.ui:ui-text:$compose_version")
                api("com.arkivanov.decompose:extensions-compose-jetbrains:$decompose_version")
                api("com.darkrockstudios:richtexteditor:1.3.0")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
                implementation("com.squareup.okio:okio-fakefilesystem:$okio_version")
            }
        }
        val androidMain by getting {
            dependencies {
                
            }
        }
        val desktopMain by getting {
            dependencies {

            }
        }
    }
This is using Android Studio Chipmunk Patch 2, but I also tried on the latest IntelliJ
a

Arkadii Ivanov

08/31/2022, 12:05 AM
Most likely this is a bug in AS, you can try the latest Electric Eel.
a

Adam Brown

08/31/2022, 4:02 AM
huh, well different error, it fails when importing the project in Electric Eel with a new error I've never seen:
Both artifact maps contains same key: C:/yy/xx/common/build/libs/common-desktop-1.0.0.jar with different values for kmp: [:common:desktopMain, :common:commonMain] and platform: [:common:desktopMain]
doesn't seem to be a common error from some initial searching
🤦
weird, it's the desktop module. if i comment it out of my
settings.gradle
then the rest of it still works
m

Mustafa Ozhan

08/31/2022, 9:11 AM
In Electric Eel I am getting the same error:
Both artifact maps contains same key:……
it actually start in canary 10
I posted here also in case someone will come up wit a solution: https://kotlinlang.slack.com/archives/CRDCFF3RC/p1661937211491259
j

Javier

08/31/2022, 10:37 AM
First I would try to build it via CLI to be sure everything is correct
x

xxfast

09/29/2022, 10:14 AM
Any update on this? I am too running into the same error on AS Electric Eel
a

Arkadii Ivanov

09/29/2022, 10:17 AM
Apparently this is still a problem in any IDE. https://github.com/JetBrains/compose-jb/issues/2340
j

Javier

09/29/2022, 10:18 AM
If you apply the original androidx compose libraries to the Android source set (
androidMain
), the IDE issue is gone.
cc @Sebastian Sellmair [JB]
I found it but in my case I have luck that my own published libraries was working perfectly, and some of the jetbrains compose libraries was working too, but only a subset of it was being marked as red, so I supposed that there is an issue in how some of those libraries are being published and/or mapped.
This happens too in pure Android libraries or Applications that are using the JetBrains Compose Gradle plugin using the compose gradle integrated dependencies with no KMP modules involved in the project
a

Arkadii Ivanov

09/29/2022, 10:23 AM
Yeah, MPP compose is published in a bit tricky way. AFAIK Android artifacts are published by Google in their own repository, and MPP Compose publishes everything else to another repository. And there is some sort of link to Android artifacts. Perhaps something is broken there.
j

Javier

09/29/2022, 10:25 AM
Maybe unpopular opinion, but I am not sure what I want more, both companies publishing one source of truth compose dependencies, or merging Android Studio into IntelliJ as I use IntelliJ as main IDE and only some edge features of Android Studio that are not in IntelliJ yet due they are Android EAPs and IntelliJ uses the stable one.
31 Views