Google Endorses Kotlin Multiplatform | Kodeco


Throughout 2017 Google I/O, Android builders rejoiced with the announcement of Kotlin as one of many predominant languages for app improvement. With the language’s steady improvement and robust group adoption, the Android crew quickly switched fully to Kotlin. From that time forth, all of the libraries have been written solely in Kotlin.

This yr, with the soundness of Kotlin Multiplatform, the growing developer adoption, and the brand new K2 compiler, Google joined the group to announce its assist for multiplatform improvement.

Be aware: This text supplies a short overview of the Kotlin Multiplatform framework. In case you are on the lookout for a deep dive, see our Kotlin Multiplatform by Tutorials e-book. It’s written by the writer of this text.

Kotlin Multiplatform

Kotlin Multiplatform, or KMP, is a expertise that enables builders to share their enterprise logic throughout a number of platforms: Android, iOS, Desktop, Net and Server. It stands out amongst cross-platform options like Flutter and React-Native as a result of its objective isn’t to have a single codebase and share your entire code however to share what is sensible to your mission. This solely pertains to your app’s enterprise logic and never UI.

There are clear benefits:

  • You don’t must commit your whole mission to a single framework: This is a vital level, particularly now that the assist from Xamarin ended. Apps that have been constructed with it now must be migrated to .NET or rewritten in… Kotlin Multiplatform.
  • You determine what’s value sharing and when: KMP adoption doesn’t carry danger to your mission. You don’t must migrate your app instantly: you can begin utilizing it when there’s a brand new characteristic to implement. Then, use it once more within the subsequent requirement and the one after. As soon as your crew is assured, you possibly can analyze if it’s value refactoring elements of your app. If it’s not, hold them as they’re. Kotlin Multiplatform is interoperable together with your current code.

Give attention to sharing the enterprise logic as a result of the UI is often carried out natively, both with XML/ Compose for Android or UIKit/Swift UI for iOS. This lets builders use native APIs to construct a extra performant and scalable app constructed on a powerful basis.

Modifications to Kotlin Multiplatform

For individuals who are already conversant in Kotlin Multiplatform, the framework has leveled up a bunch of latest additions akin to:

Android Libraries With KMP Assist

Google Docs Joins the KMP Journey!

Documentation Replace

Pattern Apps

Together with the announcement, Google launched updates in a few Android libraries, now with assist for Kotlin Multiplatform. They’re at present in several ranges of improvement. Those thought-about steady are:

Whereas the alpha variations are:

Google Docs migrated to make use of Kotlin Multiplatform for the enterprise logic, which is now shared throughout Android, iOS, and Net. Though there have been no additional particulars, the Google Workspace crew is anticipated so as to add the identical assist to different apps like Gmail, Calendar, Drive, and Meet later within the yr.

Google Docs has over one billion downloads on the Google Play Retailer and a median of 4.3 stars. These metrics are essential to point out Google’s dedication to Kotlin Multiplatform and ensure its validation on a broadly used app that must be performant to fulfill customers’ wants.

The Android crew additionally up to date the official documentation so builders can see which lessons can be found for Multiplatform. As an illustration, go to androidx.assortment to see which knowledge varieties you should use on Android, Desktop, and iOS (Native).

Android documentation for androidx.collection showing the current support for Kotlin Multiplatform

There’s now a GitHub repository for Kotlin Multiplatform samples on Android. Right here, you’ll find two pattern apps that use the libraries introduced throughout Google I/O:

Each tasks goal Android and iOS. Earlier than you’re employed on these apps, it is advisable configure your setup.

  • Android Libraries With KMP Assist

    Together with the announcement, Google launched updates in a few Android libraries, now with assist for Kotlin Multiplatform. They’re at present in several ranges of improvement. Those thought-about steady are:

    • Annotations: Use annotations in your lessons, features, and properties.
    • Collections: A set of assortment varieties and utilities.
    • DataStore: Gives a key-value knowledge storage answer.
    • Paging: Simplifies loading massive datasets by creating teams of smaller chunks (paginated) that the consumer can simply entry.
    • WindowSize Class: Defines the present dimension of a window. Use it to signify totally different display screen sizes and configurations.

    Whereas the alpha variations are:

    • Room: Android’s official library for native storage (SQLite).
    • Lifecycle: Manages the lifecycle of actions, permitting parts to regulate their conduct relying on the lifecycle state.
    • ViewModels: Shops and manages UI knowledge relying on the exercise lifecycle.
  • Google Docs Joins the KMP Journey!

    Google Docs migrated to make use of Kotlin Multiplatform for the enterprise logic, which is now shared throughout Android, iOS, and Net. Though there have been no additional particulars, the Google Workspace crew is anticipated so as to add the identical assist to different apps like Gmail, Calendar, Drive, and Meet later within the yr.

    Google Docs has over one billion downloads on the Google Play Retailer and a median of 4.3 stars. These metrics are essential to point out Google’s dedication to Kotlin Multiplatform and ensure its validation on a broadly used app that must be performant to fulfill customers’ wants.

  • Documentation Replace

    The Android crew additionally up to date the official documentation so builders can see which lessons can be found for Multiplatform. As an illustration, go to androidx.assortment to see which knowledge varieties you should use on Android, Desktop, and iOS (Native).

    Android documentation for androidx.collection showing the current support for Kotlin Multiplatform

  • Pattern Apps

    There’s now a GitHub repository for Kotlin Multiplatform samples on Android. Right here, you’ll find two pattern apps that use the libraries introduced throughout Google I/O:

    • DiceRoller: Makes use of DataStore to retailer and observe preferences.
    • Fruitties: Makes use of Room and DataStore to retailer and show knowledge.

    Each tasks goal Android and iOS. Earlier than you’re employed on these apps, it is advisable configure your setup.

As you possibly can see, KMP supplies a number of superior updates. Earlier than you possibly can actually recognize them, it is advisable get it working in your machine. Fortunately, it’s not too tough.

Putting in KMP

Earlier than opening the apps, it is advisable set up:

As soon as put in, open the pattern that you just wish to compile.


brew set up cocoapods

After synchronizing the mission, you possibly can choose which app you wish to run through configurations: androidApp or iosApp. One app targets Android units/emulators, and the opposite iOS units/simulators.

You can compile your apps to Android or iOS targets.

Right here’s DiceRoller compiled for each platforms:

DiceRoller app running on the Android emulator and on the iOS simulator

You’ll get this error as a result of the pattern makes use of an older model of AGP (Android Gradle Plugin). To unravel this, open the libs.model.toml file positioned contained in the gradle folder and search for agp. Exchange the present model with:

Synchronize the mission. Now you possibly can compile the app for each targets.

When compiling the iOSApp configuration you would possibly see the next error:

Subsequent to it, you’ll see a button with the textual content Repair on it. Click on it to open Xcode, which ought to load the proper schema.

If you happen to nonetheless see the earlier error, compile the mission immediately from Xcode.

Alternatively, you possibly can attempt to reboot your Mac.

Be aware: Relying on the model of Android Studio you’re utilizing, you would possibly see the next error when making an attempt to run your app:


Assortment accommodates no ingredient matching the predicate.

You’ll get this error as a result of the pattern makes use of an older model of AGP (Android Gradle Plugin). To unravel this, open the libs.model.toml file positioned contained in the gradle folder and search for agp. Exchange the present model with:


agp = "8.4.1"

Synchronize the mission. Now you possibly can compile the app for each targets.

When compiling the iOSApp configuration you would possibly see the next error:


Error: cannot seize Xcode schemas with /usr/bin/xcodebuild

Subsequent to it, you’ll see a button with the textual content Repair on it. Click on it to open Xcode, which ought to load the proper schema.

If you happen to nonetheless see the earlier error, compile the mission immediately from Xcode.

Alternatively, you possibly can attempt to reboot your Mac.


Assortment accommodates no ingredient matching the predicate.

agp = "8.4.1"

Error: cannot seize Xcode schemas with /usr/bin/xcodebuild

Right here’s Fruitties operating on the Android Emulator and iOS Simulator:

Fruitties app running on the Android emulator and on the iOS simulator

Be aware: To compile the iOS model, you need to set up a MacBook with Xcode on each apps.

It’s lastly time to get began!

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox