Search code examples
kotlinkotlin-multiplatformkotlin-multiplatform-mobilekmm

KMM dependencies in commonMain


If I add coroutines dependency I can use it in shared module.

But if I add my own Kotlin library with MyClass class in it, I can't see MyClass in shared module:

val commonMain by getting {
    dependencies {
        implementation(project(":myKotlinLib"))
    }
}

enter image description here

How can I mark my library module to be "compatible" with KMM shared module?

There is myKotlinLib's gradle config:

plugins {
    id 'java-library'
    id 'kotlin'
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

I've created the lib using File -> New -> Module -> Java or Kotlin library (Language: Kotlin)

UPD

I've noticed that Build tab has an error: enter image description here


Solution

  • I tried to connect a regular Kotlin library but in commonMain of module marked as kotlin("multiplatform") in plugins { ... } section we can connect only dependencies witch are kotlin("multiplatform") too