adam-mcneilly
09/19/2019, 6:09 PM<https://play.kotlinlang.org/hands-on/Targeting%20iOS%20and%20Android%20with%20Kotlin%20Multiplatform/01_Introduction>
I noticed that in this example we create a SharedCode module right inside the same folder as the Android app. Is this approach common, or is it normal to have your shared code as its own project that could be kept in its own git repository? If I do that, I'm not sure how difficult it becomes to link it to my Android app since it's no longer as simple as implementation project(':SharedCode')
. Just curious what others have done about this.Kris Wong
09/19/2019, 6:13 PMAlejandro Rios
09/19/2019, 6:14 PMJL
09/19/2019, 6:15 PMKris Wong
09/19/2019, 6:15 PMadam-mcneilly
09/19/2019, 6:18 PMKris Wong
09/19/2019, 6:30 PMadam-mcneilly
09/19/2019, 6:35 PMMiguel Fermin
09/19/2019, 6:57 PMrusshwolf
09/20/2019, 2:38 AMBenjamin Charais
09/20/2019, 3:40 AMadam-mcneilly
09/20/2019, 3:55 AMrusshwolf
09/20/2019, 11:43 AMcom.android.library
plugin and android
block. Some publishing stuff too if you need to import from another project. Details on android-specific multiplatform gradle config at https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#android-supportadam-mcneilly
09/20/2019, 12:45 PMKris Wong
09/20/2019, 12:59 PMadam-mcneilly
09/20/2019, 1:14 PMkpgalligan
09/20/2019, 3:37 PMKris Wong
09/20/2019, 3:45 PMadam-mcneilly
09/23/2019, 1:38 AMrusshwolf
09/23/2019, 1:55 AMadam-mcneilly
09/23/2019, 2:02 AMjvmMain
to androidMain
but after looking at another project, I tried this magical trick in my build.gradle and it seemed to work:
kotlin {
jvm("android")
}
Then I realized it already includes a maven-publish plugin, and there's a gradle task to publish it to my local maven repo, which is everything I want for right now!
I'm still not sure why the thing above fixed anything. Previously it was just jvm()
. Is the parameter like specifying a name for that module? I also haven't tried referencing any Android specific APIs but I don't think I'll need to. I just want to build a proof of concept with like a shared networking layer.russhwolf
09/23/2019, 2:44 AMandroid()
or android("xyz")
. The string is just a name. The function call determines the platform it’s building for.android("xyz")
would look for sources in src/xyzMain/
and src/xyzTest/
adam-mcneilly
09/23/2019, 2:56 AMExtension with name 'android' does not exist.
.
I've put the code away for now, but I can check again tomorrow and see what I did wrong. Thanks for checking though. 🙂
If I'm not using platform libraries, does it really matter then? If I can use jvm on Android then this might not be worth sinking time into.russhwolf
09/23/2019, 3:07 AMcom.android.library
pluginadam-mcneilly
09/23/2019, 3:11 AMlouiscad
09/23/2019, 5:43 AMbuildSrc
of the root project that allow smooth multiplatform dev in Android Studio or IntelliJ: https://github.com/LouisCAD/Splitties/blob/241a91f582352952813afc5ca0b06555361f74a1/modules/preferences/build.gradle.ktsKris Wong
09/23/2019, 1:08 PMAlejandro Rios
09/23/2019, 1:09 PMKris Wong
09/23/2019, 1:09 PMAlejandro Rios
09/23/2019, 1:12 PM