Android Help for Kotlin Multiplatform to Share Enterprise Logic Throughout Cell, Net, Server, and Desktop Platforms

Posted by Maru Ahues Bouza – Director, Product Administration, and Jeffrey van Gogh – Director, Engineering

Historically, builders should both write code individually for every platform they wish to goal, or make quite a few compromises with a purpose to reuse code throughout platforms. Android has been actively supporting Kotlin since 2017, and immediately we’re excited to announce we’re supporting Kotlin Multiplatform on Android, which allows sharing code throughout cell, internet, server, and desktop platforms. This helps enhance productiveness for builders, and matches nice with Android’s Kotlin-first strategy, leading to increased high quality Android apps. Our focus is to assist sharing enterprise logic (the elements which might be most agnostic to the person interfaces) as a result of we have seen Android builders get probably the most worth in not having to take care of duplicate copies of this code.

Kotlin Multiplatform (KMP) has been a long-standing funding for the crew behind Google Workspace, permitting for flexibility and velocity in delivering helpful cross-platform experiences. The Google Workspace crew is smitten by KMP’s potential because the route for its multi-platform structure funding, assured in its capacity to fulfill efficiency expectations for numerous workloads.

The preliminary step on this journey is the rollout of the Google Docs app for Android, iOS, and Net, which leverages KMP for shared enterprise logic, validating its readiness for manufacturing use at Google scale. The Google Workspace crew is thrilled to proceed exploring the probabilities of KMP throughout its product suite, aiming to reinforce productiveness and ship seamless experiences to customers on all platforms.

We see a variety of firms efficiently leveraging Kotlin Multiplatform for cross-platform improvement of their apps, find out how they apply completely different code-sharing methods here.

Kotlin Multiplatform, developed by JetBrains, offers a novel strategy to sharing code throughout platforms by compiling Kotlin to platform-native binaries. Kotlin is ready to present the complete, fashionable, reminiscence managed language to native platforms enabling native interoperability and incremental adoption. Kotlin on Android, mixed with Kotlin Multiplatform on different platforms, offers an effective way to extend productiveness and high quality, with out compromising on efficiency or interoperability.

Architecture overview for Kotlin Multiplatform (KMP)

Kotlin Multiplatform Structure

Present Standing of Help

Many widely-used libraries supply built-in assist for Kotlin Multiplatform, streamlining your cross-platform improvement expertise. These libraries work seamlessly collectively. For instance, Ktor simplifies networking duties by dealing with REST service consumption, whereas kotlinx.serialization converts knowledge to codecs like JSON, and Okio manages important file I/O. Moreover, SKIE facilitates the usage of fashionable varieties and coroutines on iOS, and CocoaPods integration allows the usage of iOS-specific dependencies.

We have labored with JetBrains and the Kotlin developer neighborhood so as to add Kotlin Multiplatform assist to quite a few Jetpack libraries and in some circumstances present the iOS platform targets, whereas in others, JetBrains and the neighborhood present the multiplatform distributions.

Right now, the Annotations, Collections, and DataStore libraries all have assist for Kotlin Multiplatform in secure variations. We’re additionally including assist to validate binary compatibility for the iOS platform targets, bringing them on a par with the standard requirements for Android. Along with the libraries above, we have additionally begun engaged on Kotlin Multiplatform assist for Room, Lifecycle, and ViewModels with alpha variations now accessible. To higher perceive which courses and capabilities can be found the place, the library reference documentation now signifies “widespread” and platform assist.

Indication of Common, Native and Android support in documentation

Indication of Frequent, Native and Android assist in documentation

Android engineers have collaborated with JetBrains on the Kotlin compiler to enhance runtime efficiency in Kotlin/Native (for iOS & native desktop working techniques), displaying 18% runtime efficiency enhancements in compiler benchmarks. As well as the Android crew contributed to construct time efficiency enhancements for the Kotlin Native Compiler of as much as 2x velocity ups.

The Android Gradle Plugin now has official assist for Kotlin Multiplatform, enabling a concise construct definition for organising Android as a platform goal for shared code as proven under:

plugins {

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "11"
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "Shared"
            isStatic = true
    sourceSets {
        commonMain.dependencies {
            // put your Multiplatform dependencies right here

KMP Help within the Android Gradle Plugin DSL

As Android Studio is predicated on the IntelliJ Platform from JetBrains, it inherits assist for Kotlin Multiplatform code modifying and plenty of different improvement options. Different Android improvement instruments like Android Lint and Kotlin Image Processing (KSP) are additionally starting so as to add extra Kotlin Multiplatform assist as nicely.

Google Chrome now has official assist for WasmGC which is utilized by Kotlin Multiplatform’s WebAssembly platform goal to allow code sharing with the browser in an environment friendly and performant means.

Newest particulars on these tasks can be found on the up to date Android Kotlin Multiplatform page.

Future Areas of Work

We have heard from many Android builders and Google engineering groups that they need expanded assist for Kotlin Multiplatform to allow them to extra simply share code with different platforms. Android plans to proceed collaborating with JetBrains, Google engineering groups, and the neighborhood on quite a lot of tasks, together with:

    • Increasing and stabilizing Jetpack libraries with Kotlin Multiplatform assist
    • Wasm platform goal assist in Jetpack libraries
    • Kotlin/Native construct efficiency
    • Kotlin/Native debugging
    • Increasing Kotlin Multiplatform assist in Android Studio

Study Extra and Attempt It Out

Sharing code with Kotlin Multiplatform between Android and different platforms allows increased developer productiveness and high quality so we hope you’ll give it a attempt! You should utilize the Kotlin Multiplatform wizard to create a brand new KMP challenge. Study extra within the documentation.

Alternatively, discover one in all these pattern tasks showcasing the way to use a number of the Jetpack libraries with Kotlin Multiplatform:

If there are further areas you want to Android to work on let us know and likewise be part of our vibrant Android Developer neighborhood on LinkedIn, Medium, YouTube, and X.

Leave a Reply

Your email address will not be published. Required fields are marked *