'Include a module as a dependency into a KMM project's shared module
I have a working KMM application, and I have a java module, mymodule, that I created with File->New->Module->Java or Kotlin library.
The module exists at the top level beside androidApp, iosApp and shared. In my settings.gradle.kts I have include(":mymodule").
I want to use mymodule in the shared module. So I go into the shared module's build.gradle.kts and I try to include my module in commonMain:
kotlin {
...
sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":mymodule"))
}
}
...
}
...
}
...
And the error is Could not resolve MyKMMApplication:mymodule:unspecified and:
Could not resolve project :mymodule.
Required by:
project :shared
Things I've tried
- I can put
dependencies { implementation(project(":mymodule")) }at the bottom ofshared'sbuild.gradle.ktsand but still the same error appears - As to test if there's other problems, I can also import
mymoduleinto the Android project without problems - I can include
implementation("com.squareup.sqldelight:runtime:1.5.3")incommonMainand see those classes in thesharedmodule no problem - The docs say you can include another multiplatform module, but nothing about a normal module.
How can I include a modules into KMM's shared module as a dependency?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
