Hi! I’m trying to add Compose Multiplatform module...
# multiplatform
c
Hi! I’m trying to add Compose Multiplatform module in my existing Android project. I wonder if there is comprehensive guide for this case. I already read Make your Android application work, but I want to know how to add Compose Multiplatform dependencies on my existing project. I tried this guide, but gradle sync always fails whenever I add each of dependencies like
implementation(compose.ui)
😭
r
a
Can you give the error?
did you apply the compose multiplatform gradle plugin properly?
c
Hi! This is the error message @Arsildo Murati
> did you apply the compose multiplatform gradle plugin properly? I believe so, but I have no idea why it doesn’t work. That’s why I want to check kind of comprehensive guideline about this, but I couldn’t find it. This is project level build.gradle.
Copy code
plugins {
    //trick: for the same plugin versions in all sub-modules
    id("com.android.application").version("8.1.2").apply(false)
    kotlin("android").version("2.0.0").apply(false)

    id("org.jetbrains.compose") version "1.6.11" apply false
    id("org.jetbrains.kotlin.plugin.compose") version "2.0.0" apply false
}
This is shared module build gradle. The one uses Compose Multiplatform.
Copy code
plugins {
    id("com.android.library")
    id("org.jetbrains.kotlin.multiplatform")
    id("org.jetbrains.compose") version "1.6.11"
    id("org.jetbrains.kotlin.plugin.compose") version "2.0.0"
}

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }


    listOf(
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            isStatic = true
        }
    }

    sourceSets {
        commonMain.dependencies {
            // This is the point that triggers error 
            implementation(compose.runtime)
            implementation(compose.ui)

        }
    }
}

android {
    namespace = "com.jetbrains.simplelogin.shared"
    compileSdk = 34
    defaultConfig {
        minSdk = 24
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    buildFeatures {
        compose = true
    }
}
I don’t know why, but after adding this code in
android
block, the error is fixed
Copy code
dependencies {
    debugImplementation("androidx.compose.ui:ui-tooling:1.6.8")
}
210 Views