https://kotlinlang.org logo
Title
d

Daniele B

06/25/2021, 11:05 AM
About creating a common project for Android and Desktop composables: Based on example provided by @darkmoon_uk https://kotlinlang.slack.com/archives/C01D6HTPATV/p1623990917153600?thread_ts=1623971327.146800&cid=C01D6HTPATV I setup the gradle file accordingly, but I still get this issue:
Here is the full gradle file for the common composable project called “composables”:
group = "eu.baroncelli.dkmpsample"
version = "1.0-SNAPSHOT"

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("org.jetbrains.compose") version Versions.jetbrainsCompose
}

kotlin {
    android ()
    jvm("desktop") {
        compilations.all {
            kotlinOptions.jvmTarget = "11"
        }
    }
    sourceSets {
        all {
            languageSettings.apply {
                useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
                 }
        }
        val commonMain by getting {
            dependencies {
                api(compose.web.widgets)
                api(compose.runtime)
                api(compose.foundation)
                api(compose.material)
            }
        }
        val desktopMain by getting {
            dependencies {
                api(compose.desktop.currentOs)
            }
        }
    }
}

android {
    compileSdk = Versions.compile_sdk
    buildToolsVersion = Versions.build_tools
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdk = Versions.min_sdk
        targetSdk = Versions.target_sdk
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
    buildFeatures {
        compose = true
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}
i

Igor Demin

06/25/2021, 11:08 AM
Add this import
l

louiscad

06/26/2021, 8:11 AM
This import:
import org.jetbrains.compose.compose
d

Daniele B

06/26/2021, 10:30 PM