Can I have a regular "android" module depend on a ...
# multiplatform
m
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
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
Can I add an android target to my lib module without having to duplicate too much of my
expect
code ?
i
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
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
@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
Yep, I forgot that the android module has the mpp plugin. That is indeed likely why it works. 👍
j
Android can depend of jvm module too I think
i
most likely yeah that should work specifying the.. classifier?
j
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