Search code examples
androidkotlinkotlin-multiplatform

Kotlin Android vs. Kotlin Multiplatform


I'm a years-long Java Android developer that recently started writing apps in Kotlin and Compose. I like it for the most part, and I'm thinking of proposing Kotlin Multiplatform to the rest of my team for a small tool we're writing.

What differences in project setup are there in vanilla Kotlin vs. Multiplatform? Assuming we wanted the app to work for Android and Desktop (in that priority order), would it be better to write an Android Kotlin/Compose app and migrate later, or start the project as Multiplatform from the ground up?


Solution

  • If you have an Android app, and you decide to add desktop support, most of your time will be spent migrating to KMP dependencies.

    So you need to know which libs are supported by desktop - I think the main thing will be navigation, as Jetpack Navigation doesn't support KMP, so you need to choose a KMP supported navigation library. I would have gone for Decompose, but you can also look for other solutions in this list of KMM libraries.

    I would suggest you start with the KMP project, add the desktop target, but do not test/run it. Write everything you can in the common module, this will prevent you from using android-only code there - you can still use it in androidMain. Adding desktop support later will be a much easier task in this case.