Android Studio:Create Kotlin multiplatform mobile application

Create your first Kotlin multiplatform mobile application in Android Studio

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

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

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

对应的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”

Step 4:

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

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

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

Step 7:

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

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

猜你喜欢

转载自blog.csdn.net/universsky2015/article/details/108633698