Hi Team, one quick question on Android KMP. I have...
# android
d
Hi Team, one quick question on Android KMP. I have a normal existing module (non KMP) which consist of only Kotlin files, Is it possible to reference this in build.gradle of commonMain in KMP module ?
a
Using below approach, it is possible to
kotlin {
// ...
sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":your-android-module-name"))
}
}
// ...
}
}
🙌 1
d
Thanks Manish for quick reply. I was trying this but it was not able to find it on import. Let me try again.
m
Is it still a KMP module but just with the common source folder?
a
sequence of clean, sync and build of .\gradlew command should work
p
What you call "normal existing module non kmp" has the kotlin - multiplatform gradle plugin applied to it? Because otherwise you won't be able to use it from commonMain
Perhaps if it has the android - library plugin applied you could import it in androidMain.
m
You can only add a dependency to
commonMain
if it is supported for all the platforms being used. So if your normal module is a JVM module, you can use it in
commonMain
if you are only targeting jvm and android. If it is an android module then you can only use it in
commonMain
if you are targeting just android. If your multiplatform module is targeting more platforms then you need the dependency to be in either
jvmMain
or
androidMain
source sets.
👆 3
👍 2