I've been meaning to use KMP with a single Android...
# multiplatform
e
I've been meaning to use KMP with a single Android target (maybe also JVM just to prevent Android from leaking into the common code) for my Android projects going forward. The only thing holding me back had been the new KMP plugin not being available for Android Studio, but with it being supported in Otter, I'm looking at this again. My reasoning is that it should be pretty straightforward to support, and would go a long way towards adding ios, web, etc... if ever needed. Anyone doing this and run into any issues, anything to look out for, etc...? Is this a bad idea for some reason I'm not thinking of?
j
Common means common to all your specified targets, not common to all possible targets. Adding JVM will prevent Android dependencies from leaking into your common code, but it won't stop Java APIs.
6
Even having iOS would still let you use things like
runBlocking
from kotlinx.coroutines in common, but then adding a JS or Wasm target sometime later will make that unavailable in common.
4
e
I know, I'm mostly "concerned" about Android because I tend to use KMP ready libraries for most things that I would use the JDK for, but still have things like
Context
in my implementations
e
you can do that with the current com.android.library plugin, and then migrate to com.android.kotlin.multiplatform.library later. it's a straightforward migration as long as you're not using functionality that the latter doesn't have (variants or plugins trying to interact with the old android plugin)
e
To clarify, I'm not currently using KMP at all. I would start using it, migrate the source sets, etc...
j
The value in doing that work seems questionable
I guess if you have plenty of free time, but I would defer doing this as long as possible
e
It's for a rapidly growing project, so I'm treating it more like a hedge against having to do it when the project is even larger.
e
j
Yeah, although we went the other way. It was JVM for 12 years and it still linked against Android APIs but only loaded that type if Android was detected.
The change was so we could deliver a file through assets instead of as a class resource