https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
m

moltendorf

02/01/2020, 7:27 PM
Hi all, I’ve mostly got a multiplatform library working; sans a couple of issues when I attempt to add a few things: • In the android `actual`s, I can’t seem to access android packages/classes (i.e.
android.os.Build
) • When I add a second
jvm()
target (for the server), the library builds, but the android app is no longer able to resolve dependencies.
r

russhwolf

02/01/2020, 7:40 PM
Use
android()
instead of
jvm()
for your Android target. You’ll also need to apply one of the android gradle plugins (probably
com.android.library
) and include an
android {}
block that sets
minSdkVersion
and
compileSdkVersion
.
m

moltendorf

02/01/2020, 7:45 PM
I started doing that, but then felt at odd with the number of additional things I started adding. I guess it was right all along, so the next error about the manifest: I’ll add one and keep on in that for now?
r

russhwolf

02/01/2020, 7:45 PM
Yeah you need a manifest too
Android plugin still needs all its usual structure
m

moltendorf

02/01/2020, 7:47 PM
I would still use:
Copy code
sourceSets["androidMain"].dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
?
(for initial and future dependencies) of course
r

russhwolf

02/01/2020, 7:48 PM
yeah
though you can also add android-specific dependencies there if needed
which you can’t in a JVM target
m

moltendorf

02/01/2020, 7:56 PM
Now I feel I should go figure out Gradle some more.
r

russhwolf

02/01/2020, 7:56 PM
m

moltendorf

02/01/2020, 7:57 PM
Have been. This is just my first multiplatform since I’ve been watching/learning/etc all these years.
id("com.android.*library*")
yep… that fixed it I think.
Thanks for the help!
👍 1
d

Dariusz Rusin

02/03/2020, 6:23 AM
You have to keep in mind that android libs cannot be used by pure java/kotlin modules if you have some of them in project.