Hello! How to write only one function for `android...
# multiplatform
z
Hello! How to write only one function for
androidMain
and
jvmMain
in KMP? Because it uses Java library, I can't put it into
commonMain
. I had to write two copies of the same code in
androidMain
and
jvmMain
e
create new intermediate source sets,
Copy code
kotlin {
    jvm()
    androidTarget {
        // ...
    }

    applyDefaultHierarchyTemplate {
        common {
            group("jvmAndAndroid") {
                withJvm()
                withAndroidTarget()
            }
        }
    }
}
where the group
jvmAndAndroid
results in
jvmAndAndroidMain
,
jvmAndAndroidTest
source sets
z
@ephemient Thank you so much! ❤️