I'm working on a multiplatform compose project, bu...
# multiplatform
a
I'm working on a multiplatform compose project, but I can't seem to get dependencies to include properly in my
commonMain
module. I add the dependency the way I assume it should work, but it doesn't seem to be included when I'm in source files in
commonMain
any ideas what I could be doing wrong?
Huh, it even kinda sorta knows that it exists
a
Maybe import?
a
Import imports an unrealted class from the JVM
a
Could you please post the whole
build.gradle
content?
a
sure thing, and thanks for your help today
Copy code
import org.jetbrains.compose.compose

plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose") version "0.2.0-build132"
    id("com.android.library")
    id("kotlin-android-extensions")
}

group = "com.darkrockstudios.apps"
version = "1.0"

repositories {
    google()
    jcenter()
}

kotlin {
    android()
    jvm("desktop") {
        compilations.all {
            kotlinOptions.jvmTarget = "15"
        }
    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                api(compose.runtime)
                api(compose.foundation)
                api(compose.material)
                api(compose.ui)

                implementation("com.arkivanov.decompose:decompose:0.1.8")
                implementation("com.arkivanov.decompose:extensions-compose-jetbrains:0.1.8")
            }
        }
        val commonTest by getting
        val androidMain by getting {
            dependencies {
                api("androidx.appcompat:appcompat:1.2.0")
                api("androidx.core:core-ktx:1.3.2")
                implementation("com.arkivanov.decompose:extensions-compose-jetpack:0.1.8")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation("junit:junit:4.13.1")
            }
        }
        val desktopMain by getting {
            dependencies {

            }
        }
        val desktopTest by getting
    }
}

android {
    compileSdkVersion(29)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(29)
    }
}
the project template is from the default
New Project -> KMM Compose
option
a
The first thing that is noticeable is that you are using a very old Compose version
a
And the file lives inside
commonMain
oh!
a
Please try
0.3.0-build152
, it is proved working
And make sure you are using Kotlin 1.4.30
a
yes, I am on 1.4.30, recompiling w\ compose
0.3.0-build152
ok thats fine
hasn't changed anything related to the dependency issue though
a
Did you sync the project?
a
yes
a
Could you please try removing
Copy code
compilations.all {
            kotlinOptions.jvmTarget = "15"
        }
a
that started as 11, but it crashed on run with an error about requiring 14 or greater
a
What JDK version you are using?
a
I have 2 installed it looks like, 11 & 15
just to clear 1 thing up, this IS the way I would normally include dependencies to the common module in KMM? There's nothing social or magical going on here?
a
The dependencies config looks fine to me
You can try removing compose plugin and its deps and see if imports work
Compose for Desktop requires at least JDK 14 AFAIK
Also you can try to manually import
import com.arkivanov.decompose.ComponentContext
a
that. does. work.
what the heck lol
manual import that is
removing the compose plugin didnt help
a
Then maybe an IDE error or something, hard to tell. What IDE you are using?
a
IntelliJ Ultimate
a
Should be fine I guess
You can try invalidate caches/restart as usual
a
as is tradition
🧌 1
a
Last thing: do you have Kotlin plugin up to date?
a
no its up to date
huh, well I can manually include for now I suppose
still early days for KMM and all that
a
Weird, never seen this bug. Maybe try another IDE, e.g. I'm using Community IDEA (not Ultimate) and Android Studio Beta. Also JFY
kotlin-android-extensions
is deprecated, you should use
kotlin-parcelize
for
@Parcelize
a
oh nice, thanks
ha, I didn't realize you were the library author 😛
K 1
it seems to have gotten even more mad:
🤯 2
d
try to delete .idea folder