Hey guys, quick question from someone who used KMM...
# multiplatform
d
Hey guys, quick question from someone who used KMM last time two years ago. In a multi-module project, is it better to have a separate app module per client or a single multi-platform module? ( Note that for now I’ll focus on Android only ) I created an
app
module Jvm+Android, but I’ve seen a very old problem on Android Studio, which is the “Unresolved reference” for components from multiplatform modules. It compiles, but it’s impossible to work in this way. Any drawback in having an
app
module that is KMM+Android only?
b
Recommended practice is to have kmp lib modules consumed by standalone app modules per target
That way you can move more freely with your app setup without being coupled to other targets
d
Thanks. Sorry I realized I explained it poorly. What you mentioned is my plan, but question is: should the Android
app
module be: 1. Standard JVM + Android 2. Kotlin Multiplatform ( with Android only )
Because the first one seems to cause issues in Android Studio with “unresolved reference”
b
Option one. i.e. app modules do not use kmp plugin (except for ios world where there are no other alternatives)
Does your kmp lib module declare jvm, android or both targets?
Also how are you applying it to the app module?
d
jvm only,
b
If your project is oss i could have a proper look for issues
d
Ok, let me push my most recent changes
👍 1
b
Wait, the project is not a mpp project
It's a jvm-only project with gradle and kotlin plugins
What am I missing?
d
look in
cinescout
dir 😄
b
Could you pinpoint me to some module where you;re observing issues with current setup?
d
For example
android/app
, in the file
AppModule.kt
,
CineScoutModule
is not resolved
The project builds correctly tho
b
Ah, might be a case of IDEA not supporting KMP composite builds yet.
They work in some cases, but in the others you need to publish your KMP stuff to mavenLocal() or similar before being able to resolve it
🤯 1
d
That’s terrible 😄
b
Not ideal, but not that bad too. Just an extra intermediate
gradle publishToMavenLocal
step
d
How do you suggest to integrate it? Is there any article or doc about it?
b
Not aware of any docs for it. Still waiting for IJ to finish indexing your project and then I'll see what can be tweaked to make it work semi-conveniently
d
Ok, thank you so much
b
No worries. I use these pesky issues as an opportunity to teach myself stuff, makes learning interesting 😄
d
I rather learn other stuff, than fixing build issues 😛
😅 2
b
Welp, got an easy fix for you
d
😵
b
No code changes needed, just bump tour intellij to 2022.2-RC 😄
d
I’m actually on Android Studio, can I build it from IntelliJ?
b
You sure can
d
Community Edition as well?
b
But you'll need an IJ Ultimate which is not free...
d
Yep, indeed 😛 I had the licence, but I found myself not using it for exactly 2 years 😄
b
Otherwise you'll either have to wait for AS to catch up on the newer builds of IJ or fully decouple your gradle included builds and instead use mavenLocal() repository
d
Oh wait, I’d need to publish only the composite builds, aka Gradle plugins to Maven local?
b
Correct
d
I understood I’d need to publish my whole kmp bundle of libs 😄
Ok, so that’s acceptable
b
then in your app modules you'd apply the plugins as normal (with version specified) and declare mavenLocal() as a top plugins repo
d
Ok, sounds great!
b
Give it a go and ping back here if you still get stuck. Remember, key point here is to simply avoid gradle included (composite) builds in your project
d
Would that be required for every plugins or only the ones applied to my Android modules? (
Ok, I guess you already answered me then 🙂
b
Anything that you currently are applying via included build
d
Ok, I’ll give it a go later or maybe in the week-end, as that’s my pet project and I’m supposed to work now 😛 I’ll ping you back! Thank you so much for now!
b
No worries, good luck
K 1
d
I gave it a try, but doesn’t seems like it got solved 😞
I took a look on the net by the way, I seen the issues you mentioned, but only when the dependency is actually from a composite build, while my only composite build are the Gradle plugins: the
app
modules uses other modules inside
cinescout
directory, which are other modules of the same project
Nvm, it actually works like a charm on IntelliJ CE. Why do I even use Android Studio? 🤣
b
Wait what? Ij CE supports android development??
I could've sworn you needed ultimate for that!
d
Seems like it 🙂 i actually read on JetBrains website yesterday and they said so. 2022.1 it tells me I need at least IntelliJ 2021.something, on 2022.2 rc all smooth
Impressively even the speed I built and run and Android app. I'd take 3x times with Android Studio
b
Good to know!