https://kotlinlang.org logo
p

pajatopmr

03/31/2019, 12:31 PM
So I am trying to add the Android platform to a multiplatform library using IntelliJ. Is there an example that shows the Gradle build script using Kotlin that someone would care to recommend? Gradle version is 5+ fwiw.
My first dilemma is in trying to come up with a version for the com.android.library plugin. Would that be the Android version, like 28.0.0? Second dilemma is the repository to use to access the plugin. Wouldn’t that be google()?
r

russhwolf

03/31/2019, 2:09 PM
The
com.android.library
plugin version would be
3.3.2
if you want the latest stable version, or
3.4.x
or
3.5.x
if you’re using a beta or canary Android Studio. And yes,
google()
is the repository you want
Ildar’s link will give you more configuration hints
p

pajatopmr

03/31/2019, 6:14 PM
@thevery @russhwolf Sorry I did not get this across more clearly but the goal is to use a Kotlin script rather than a Groovy script. And IntelliJ rather than Android Studio.
t

thevery

03/31/2019, 6:44 PM
IJ vs AS doesn't matter for build script
l

louiscad

03/31/2019, 6:48 PM
Here's an Android targetting only "multiplatform" library example that relies of the content of the
buildSrc
of that same project: https://github.com/LouisCAD/Splitties/blob/master/modules/toast/build.gradle.kts
1
r

russhwolf

03/31/2019, 6:50 PM
https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html has code samples in both Kotlin and Groovy if you need help translating.
2
p

pajatopmr

03/31/2019, 7:35 PM
@russhwolf this doc elides out the translation details much to my chagrin. 😞 However, the @louiscad Splitties repo does an excellent job showing the translations, but it took some digging to find them. Splitties is a great teaching resource.
l

louiscad

04/01/2019, 6:34 AM
I could do it only thanks to the doc Russell linked 🙂
3 Views