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

bod

01/16/2020, 6:03 PM
Hello, World! Does anyone know if it's possible to have a MP project that both publishes an Android library artifact (.aar), and contains an Android app sample. It appears to me that I find samples that either apply the
com.android.library
gradle plugin (to publish an aar artifact) or the
com.android.application
one (to have a sample app) - but of course you can't apply both. Ideas?
b

Big Chungus

01/16/2020, 6:05 PM
That was possible with the old MPP plugins, where each target is a separate module rather than a sourceSet. Not so sure now 😕
s

Sean Keane

01/16/2020, 6:06 PM
Build your aar in common as a library. Then you can have an application project that consumes that module and expose the application through that. What is it you are trying to achieve exactly?
b

bod

01/16/2020, 6:08 PM
well I'm trying to have a MP library to be consumed by Android and iOS and it would be nice if it contained a sample app in such a way that if I open the project in the IDE, I can just run the app. Instead of having a separate sample app project.
I think @Sean Keane you're saying that it should be a separate project, right?
s

Sean Keane

01/16/2020, 6:10 PM
All you need is a separate module
b

bod

01/16/2020, 6:10 PM
oh! of course 🙂
didn't think of that
s

Sean Keane

01/16/2020, 6:10 PM
You can run the app from the app module and use your common code between both
b

bod

01/16/2020, 6:11 PM
perfect 🙂 Thanks a lot
b

Big Chungus

01/16/2020, 6:11 PM
Not really. I had same issue with the MPP library I'm working on as well. What I did was just a separate gradle module for the app that depends on the lib via
implementation(project(":libModuleName"))
b

bod

01/16/2020, 6:11 PM
yeah that makes sense now that I think of it 🙂
s

Sean Keane

01/16/2020, 6:11 PM
^ yep. Separate module for the application that implements the library
b

bod

01/16/2020, 6:11 PM
👍 thanks all!
👍 1