https://kotlinlang.org logo
m

mbonnin

04/28/2020, 9:08 PM
Can I have a regular "android" module depend on a "multiplatform" module (with a jvm target) using something like
implementation(project("lib"))
? That doesn't seem to work.
k

Kris Wong

04/28/2020, 9:15 PM
i would not expect that to work. an Android target, maybe, but not a JVM target
i don't know enough of the Gradle and Android Gradle plugin internals to say with certainty, though
m

mbonnin

04/28/2020, 9:16 PM
Can I add an android target to my lib module without having to duplicate too much of my
expect
code ?
i

ian.shaun.thomas

04/28/2020, 9:17 PM
the problem with adding an android variant is if anyone wants to write some common jvm code based on your lib then use that code in their android project alongside your android lib they have an immediate issue. you can see in that project I took a pretty awkward step to build the core module, then android, then package them together for deployment so you can have jvm code and the android code in the same consumer project without consequence. I think if I did it again I would just have android as a totally separate implementation
k

Kris Wong

04/28/2020, 9:26 PM
i would expect a project dependency to work with 2 KMP modules. but not a project KMP dependency in a standard android project
i don't know how it would find the target file it needs in the KMP targets
m

mbonnin

04/28/2020, 10:42 PM
@ian.shaun.thomas that worked like a charm👌🏽 . I added the multiplatform plugin and put everything in
androidMain
and it looks like it's working well. So @Kris Wong was right too that a regular android project would most likely not work.
i

ian.shaun.thomas

04/28/2020, 11:36 PM
Yep, I forgot that the android module has the mpp plugin. That is indeed likely why it works. 👍
j

Javier

04/28/2020, 11:37 PM
Android can depend of jvm module too I think
i

ian.shaun.thomas

04/28/2020, 11:37 PM
most likely yeah that should work specifying the.. classifier?
j

Javier

04/28/2020, 11:40 PM
Mmm I have to try, because in my original multiplatform module, the Android Target is using jvm too so I don't know what happen if Android didn't use jvm and you don't set the classifier. Hope it adds both, JVM and Android
3 Views