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

Adam Brown

02/20/2021, 10:05 PM
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

Arkadii Ivanov

02/20/2021, 10:42 PM
Maybe import?
a

Adam Brown

02/20/2021, 10:43 PM
Import imports an unrealted class from the JVM
a

Arkadii Ivanov

02/20/2021, 10:44 PM
Could you please post the whole
build.gradle
content?
a

Adam Brown

02/20/2021, 10:44 PM
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

Arkadii Ivanov

02/20/2021, 10:47 PM
The first thing that is noticeable is that you are using a very old Compose version
a

Adam Brown

02/20/2021, 10:47 PM
And the file lives inside
commonMain
oh!
a

Arkadii Ivanov

02/20/2021, 10:48 PM
Please try
0.3.0-build152
, it is proved working
And make sure you are using Kotlin 1.4.30
a

Adam Brown

02/20/2021, 10:48 PM
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

Arkadii Ivanov

02/20/2021, 10:49 PM
Did you sync the project?
a

Adam Brown

02/20/2021, 10:49 PM
yes
a

Arkadii Ivanov

02/20/2021, 10:50 PM
Could you please try removing
Copy code
compilations.all {
            kotlinOptions.jvmTarget = "15"
        }
a

Adam Brown

02/20/2021, 10:51 PM
that started as 11, but it crashed on run with an error about requiring 14 or greater
a

Arkadii Ivanov

02/20/2021, 10:54 PM
What JDK version you are using?
a

Adam Brown

02/20/2021, 10:55 PM
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

Arkadii Ivanov

02/20/2021, 10:56 PM
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

Adam Brown

02/20/2021, 10:59 PM
that. does. work.
what the heck lol
manual import that is
removing the compose plugin didnt help
a

Arkadii Ivanov

02/20/2021, 11:00 PM
Then maybe an IDE error or something, hard to tell. What IDE you are using?
a

Adam Brown

02/20/2021, 11:00 PM
IntelliJ Ultimate
a

Arkadii Ivanov

02/20/2021, 11:00 PM
Should be fine I guess
You can try invalidate caches/restart as usual
a

Adam Brown

02/20/2021, 11:00 PM
as is tradition
🧌 1
a

Arkadii Ivanov

02/20/2021, 11:02 PM
Last thing: do you have Kotlin plugin up to date?
a

Adam Brown

02/20/2021, 11:03 PM
no its up to date
huh, well I can manually include for now I suppose
still early days for KMM and all that
a

Arkadii Ivanov

02/20/2021, 11:13 PM
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

Adam Brown

02/20/2021, 11:17 PM
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

Dragos Rachieru

02/26/2021, 8:20 AM
try to delete .idea folder