Getting Started with Kotlin Multiplatform Mobile [KMM]

Ngima Sherpa
3 min readSep 1, 2021

KMM[Kotlin Multiplatform Mobile] is a way to build cross platform apps with shared Kotlin code among Android Native View and Swift Native View so the idea is to share the business logic among multiple platform.

In this article, I will basically share my experience with getting started with KMM in general. And also will share some useful links at the end.

Preface

I am mobile developer and I mostly worked on Native Android Apps Development. I tried KMM with a KMM projects in Github 1 year but I didn’t do much. Oh wait I noticed I wrote an article at that time but didn’t publish it😒.

Draft preview of article I wrote 1 year ago about KMM

I am very interested on continuing with Kotlin Multiplatform Mobile after working on couple of React Native Projects on which I am not so much happy with the performance of the apps.

As Android Developer I use Kotlin which is plus point for KMM to try it out. Let’s get started with KMM. Before that I assume you have Android Studio already installed in your Machine. If not don’t worry you could download and install it from Android Developer Official Site.

Now, Let’s dive in 👍.

Getting Started

Step 1: Installing Kotlin Multiplatform Mobile Plugin

Install Kotlin Multiplatform Mobile Plugin in Android Studio and restart the Android Studio

Installing Kotlin Multiplatform Mobile Plugin

Step 2: Creating Your First KMM Project

Now you could create new KMM project via Android Studio’s Create Project Wizard. You could see KMM Application as a last template option as in Screenshot below.

Android Studio’s New Project Wizard with KMM Application option

Press Next and fill additional informations and Press Finish Button after all information are field.

Now Android Studio will install download some files and you’re ready to go.

Step 3: Understanding Project file structure

After creating the project, you could see file structure as shown in screenshot. You can notice three folders androidApp, iosApp & shared, we could set other names for these folder while we’re creating the KMM project via Android Studio Create Project Wizard.

KMM Project file structure

Folder androidApp contains the regular android native app. You could run Android App directly from the android studio.

Folder iosApp contains regular iOS native App Project. For running iOS App, You must have MacOS & Xcode installed in your Machine.

Folder shared contains all codes that will be shared among Native Android & iOS Projects. Where we will place the business logic that can be shared among multiple mobile platform.

Step 4: Running application

Select each platform in run configurations with androidApp to run Android Application & iosApp to run iOS Application. And click on green play/run button as shown in Screenshot below.

Initial output of project created using KMM Android Studio Plugin

This is just a brief guide for Getting Started with KMM. I have started to explore KMM. I am starting personal learning project kmm-7-days where I will document my progress on KMM. I update what I have learned through out my 7 days of KMM learning in next KMM article. 😊

Useful Links

KMM Documentation: Here you could find complete guide for KMM.

Ktor: Used for networking in KMM.

--

--

Ngima Sherpa
Ngima Sherpa

Written by Ngima Sherpa

Mobile Developer | UI Designer

No responses yet