Colton Idle
03/29/2021, 10:48 AMcomposables-common
I already created this module in Android Studio as a new android library module. Now I want to create a new module in the same project that is a compose desktop module and have it depend on composables-common
Two questions:
1. Is making my composables-common module supposed to be a com.android.library
module?
2. Does anyone see any issue with my "proposed" setup? Existing android app module. Create new composables-common android library module. Set this composables-common as a dependency in my existing app module. Create new compose desktop app plain ol java module. Depend on composables-common dependency in the desktop module. Working on Android? Open the project in AS and choose android app module to launch. Working on desktop? Open the project in IJ and choose desktop app module to launch.
I have seen the sample projects showing desktop and android app in a single repo, but I guess I'm more stuck on how to do it for an already existing project. Thank you!Igor Demin
03/29/2021, 11:17 AMcomposable-common
in desktop
module, both composable-common
and desktop
should be MPP modules (i.e you should apply kotlin("multiplatform")
in build.gradle).
Your common code in composable-common
should also be in commonMain
instead of jvmMain
or main
So your steps will be:
1. create composables-common
in Android Studio
2. convert this module to MPP (apply MPP plugin, move sources to commonMain
). com.android.library
should stay
3. Create desktop
MPP module (not plain java, because this is not properly supported by IDE yet). android
module can remain as a plain android module, not as MPP.
4. depend `desktop` module on composable-common
5. depend `android` module on composable-common
P.S. Probably there is another option - not to create separate modules desktop
/ android
. And just keep the single MPP module app
with desktopMain
and androidMain
sourcesets. But I haven't tried this 🙂Colton Idle
03/29/2021, 12:01 PMdesktop
 MPP module". Would I just open my project directory in IJ and create a module from there? Or should I try to add the module from android studio?Colton Idle
03/29/2021, 12:08 PMIgor Demin
03/29/2021, 12:18 PMColton Idle
03/29/2021, 11:45 PMconvert this module to MPP (apply MPP plugin, move sources toÂTried to convert my module to an MPP module. I think it's because by default AS creates modules with build.gradle instead of build.gradle.kts and when I try to do that... everything seems to just stop working in the IDE. Syntax highlighting, auto completion, etc.).ÂcommonMain
 should staycom.android.library
Igor Demin
03/30/2021, 8:54 AMandroidx.compose
, you have to switch your project to `org.jetbrains.compose`:
0. Apply plugin id("org.jetbrains.compose")
instead of compose true. Remove all explicit dependencies on androidx.compose
And instead of creating a new module composable-common
and converting it to MPP it is also easier to just copy it from hereColton Idle
03/30/2021, 9:16 AMColton Idle
03/30/2021, 9:31 AMIgor Demin
03/30/2021, 9:39 AMColton Idle
03/30/2021, 9:55 AMColton Idle
03/30/2021, 10:01 AMColton Idle
03/30/2021, 10:02 AMColton Idle
03/30/2021, 10:02 AMColton Idle
03/30/2021, 10:03 AMIgor Demin
03/30/2021, 10:03 AMColton Idle
03/30/2021, 10:09 AMColton Idle
03/30/2021, 10:09 AMColton Idle
03/30/2021, 10:10 AMColton Idle
03/30/2021, 10:19 AM