Create your first Kotlin multiplatform mobile application in Android Studio

Android Studio:Create  Kotlin multiplatform mobile application_https

In this article, you are going to build a simple hello world application that will run in Android and IOS with a single codebase using Kotlin programming language.

Firstly, I will like to explain what is Multiplatform, its benefits, and how to implement it in your codebase.

What is Multiplatform?

If a software program is developed for multiple operating systems, it is considered to be “multiplatform.” meaning its capable of running on two or more different hardware platforms.

I believe it's clear now, lets get to know what is Kotlin Multiplatform

Kotlin Multiplatform

Android Studio:Create  Kotlin multiplatform mobile application_qt_02

Kotlin Multiplatform Mobile allows you to use a single codebase for the business logic of iOS and Android apps. Sharing code between mobile platforms is one of the major Kotlin Multiplatform use cases. With Kotlin Multiplatform Mobile (KMM), you can build multiplatform mobile applications sharing code, such as business logic, connectivity, and more, between Android and iOS.

For more info check out this link: https://kotlinlang.org/lp/mobile/

Steps of building a kotlin multiplatform mobile application

Kindly follow the simple steps to create your first Kotlin Multiplatform Mobile project.

Step 1:

Install Kotlin Multiplatform Mobile plugin in Android studio

Open your Android Studio -> Click Configure -> Select Plugins

Android Studio:Create  Kotlin multiplatform mobile application_https_03

You can alse download kmm plugin :

​https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile/versions/stable​

and drop the zip package to Android Studio Window to intall it.

Step 2:

Select Marketplace in the plugin p and search for “KMM”, Install it and restart your Android studio

Android Studio:Create  Kotlin multiplatform mobile application_ai_04

对应的Kotlin 插件版本基本需要适配:

​https://plugins.jetbrains.com/plugin/6954-kotlin/versions​

kotlin-plugin-1.4.10-release-Studio4.2-1.zip

kmm-plugin-0.1.1-release-42-Studio4.0.zip

Step 3:

In the Android studio first screen Select “ Start a new Android Studio project”

Android Studio:Create  Kotlin multiplatform mobile application_mysql_05

Step 4:

In the “ Select a project Template” screen, select “KMM Application”

Android Studio:Create  Kotlin multiplatform mobile application_https_06

Step 5:

In this p, you will have to give your project a name, select your minimum SDK, Save location, and Package name. then you will click the finish button

Android Studio:Create  Kotlin multiplatform mobile application_nagios_07

Now, you will have to wait while your project is set up for the first time. It may take some time to download and set up the required components.

Step 6:

You can start coding your Kotlin multiplatform mobile project now

Android Studio:Create  Kotlin multiplatform mobile application_ai_08

Step 7:

Let's run our Helloworld Application by clicking on the play button

Android Studio:Create  Kotlin multiplatform mobile application_mysql_09

Android Studio:Create  Kotlin multiplatform mobile application_https_10

​https://medium.com/@wise4rmgodadmob/create-your-first-kotlin-multiplatform-mobile-application-in-android-studio-e79b855a030b​