{"id":232537,"date":"2024-06-14T22:47:24","date_gmt":"2024-06-14T22:47:24","guid":{"rendered":"https:\/\/michigandigitalnews.com\/index.php\/2024\/06\/14\/android-support-for-kotlin-multiplatform-kmp-to-share-business-logic-across-mobile-web-server-and-desktop\/"},"modified":"2025-06-25T17:17:02","modified_gmt":"2025-06-25T17:17:02","slug":"android-support-for-kotlin-multiplatform-kmp-to-share-business-logic-across-mobile-web-server-and-desktop","status":"publish","type":"post","link":"https:\/\/michigandigitalnews.com\/index.php\/2024\/06\/14\/android-support-for-kotlin-multiplatform-kmp-to-share-business-logic-across-mobile-web-server-and-desktop\/","title":{"rendered":"Android Support for Kotlin Multiplatform (KMP) to Share Business Logic Across Mobile, Web, Server, and Desktop"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div>\n<meta content=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEghr-7IZVE8USRGsSdWW2t6B8XPpcRtpq32qzgTS2h-nER09-_zUGP3YMtZszJwOLeyNVufbJZNqryAMmt-7fS5kUOX6D09WrbxmAMwyFj8hOrgWaPE-E-fyryL7tNQSW163L9FqQFWGv_OtGDS95yves1cV3bpkQXAy77gIsm0u2sZPeJK78fEdQCMlac\/s1600\/Kotlin-Android-KMP-support-metacard-3.png\" name=\"twitter:image\"\/><br \/>\n<img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEghr-7IZVE8USRGsSdWW2t6B8XPpcRtpq32qzgTS2h-nER09-_zUGP3YMtZszJwOLeyNVufbJZNqryAMmt-7fS5kUOX6D09WrbxmAMwyFj8hOrgWaPE-E-fyryL7tNQSW163L9FqQFWGv_OtGDS95yves1cV3bpkQXAy77gIsm0u2sZPeJK78fEdQCMlac\/s1600\/Kotlin-Android-KMP-support-metacard-3.png\" style=\"display: none;\"\/><\/p>\n<p><em>Posted by Maru Ahues Bouza \u2013 Director, Product Management, and Jeffrey van Gogh \u2013 Director, Engineering<\/em><\/p>\n<p><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgaziKHPDi-lU9XBgPSwip4VGn66K9Nh9NTiX3NVBieZWINs3IFqmu1bTJGojxSVktO7U2mVp6KjtcNTMWVUN8jBBDb7-7r5oJpoWJX6uRluGQot0OPKPDQVQjH3KDPKo1A6hMfYuAdBJgF4W6Fjbvi7LzR6cY8ps2s2yLgsVYi7e36cHC8n40Z20A8DI4\/s1600\/Kotlin-Android-KMP-support-banner-3.png\"><img decoding=\"async\" border=\"0\" data-original-height=\"800\" data-original-width=\"100%\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgaziKHPDi-lU9XBgPSwip4VGn66K9Nh9NTiX3NVBieZWINs3IFqmu1bTJGojxSVktO7U2mVp6KjtcNTMWVUN8jBBDb7-7r5oJpoWJX6uRluGQot0OPKPDQVQjH3KDPKo1A6hMfYuAdBJgF4W6Fjbvi7LzR6cY8ps2s2yLgsVYi7e36cHC8n40Z20A8DI4\/s1600\/Kotlin-Android-KMP-support-banner-3.png\"\/><\/a><\/p>\n<p>\nTraditionally, developers must either write code individually for each platform they want to target, or make a number of compromises in order to reuse code across platforms.  Android has been actively supporting Kotlin since 2017, and today at Google I\/O we are excited to announce <strong>we are supporting Kotlin Multiplatform on Android<\/strong>, which enables sharing code across mobile, web, server, and desktop platforms.  This helps increase productivity for developers, and fits great with Android&#8217;s <a href=\"https:\/\/developer.android.com\/kotlin\/first\" target=\"_blank\" rel=\"noopener\">Kotlin-first<\/a> approach, resulting in higher quality Android apps.  Our focus is to support sharing business logic (the parts that are most agnostic to the user interfaces) because we&#8217;ve seen Android developers get the most value in not having to maintain duplicate copies of this code.\n<\/p>\n<p>\nKotlin Multiplatform (KMP) has been a long-standing investment for the team behind Google Workspace, allowing for flexibility and speed in delivering valuable cross-platform experiences. The Google Workspace team is enthusiastic about KMP&#8217;s potential as the direction for its multi-platform architecture investment, confident in its ability to meet performance expectations for various workloads.\n<\/p>\n<p>\nThe initial step in this journey is the rollout of the Google Docs app for Android, iOS, and Web, which leverages KMP for shared business logic, validating its readiness for production use at Google scale. The Google Workspace team is thrilled to continue exploring the possibilities of KMP across its product suite, aiming to enhance productivity and deliver seamless experiences to users on all platforms.\n<\/p>\n<p>\nWe see a lot of companies successfully leveraging Kotlin Multiplatform for cross-platform development of their apps, learn how they apply different code-sharing strategies <a href=\"https:\/\/www.jetbrains.com\/help\/kotlin-multiplatform-dev\/case-studies.html\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>\nKotlin Multiplatform, developed by JetBrains, provides a novel approach to sharing code across platforms by compiling Kotlin to platform-native binaries. Kotlin is able to provide the full, modern, memory managed language to native platforms enabling native interoperability and incremental adoption. Kotlin on Android, combined with Kotlin Multiplatform on other platforms, provides a great way to increase productivity and quality, without compromising on performance or interoperability.\n<\/p>\n<div class=\"separator\" style=\"clear: both;\"><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjdAZ35Bb74cH_YV_sUjFwh2qsiMCpG-P-YV4S8DQon88Gs9nF3kiX_57ubTLCcx-B_gDAS2w8o_9layOVtFohOJRSW_o_PNN_x-9IDOpHWRiNXRIbjF9h7ca9uRyZ0E6k914DtGZNhouU2yY7-bL0FHJX4D5mawqEluxMotvLYgM68ouddlrEatZXzmbs\/s1600\/image1.png\" style=\"display: block; padding: 1em 0px; text-align: center;\"><img fetchpriority=\"high\" decoding=\"async\" alt=\"Architecture overview for Kotlin Multiplatform (KMP)\" border=\"0\" data-original-height=\"959\" data-original-width=\"1999\" height=\"307\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjdAZ35Bb74cH_YV_sUjFwh2qsiMCpG-P-YV4S8DQon88Gs9nF3kiX_57ubTLCcx-B_gDAS2w8o_9layOVtFohOJRSW_o_PNN_x-9IDOpHWRiNXRIbjF9h7ca9uRyZ0E6k914DtGZNhouU2yY7-bL0FHJX4D5mawqEluxMotvLYgM68ouddlrEatZXzmbs\/w640-h307\/image1.png\" width=\"640\"\/><\/a><\/div>\n<p><i><\/p>\n<p><i>Kotlin Multiplatform Architecture<\/i><\/p>\n<p><\/i><br \/>\n<\/p>\n<h3>Current Status of Support<\/h3>\n<p>\nMany widely-used libraries offer built-in support for Kotlin Multiplatform, streamlining your cross-platform development experience. These libraries work seamlessly together. For example, <a href=\"https:\/\/ktor.io\/\" target=\"_blank\" rel=\"noopener\">Ktor<\/a> simplifies networking tasks by handling REST service consumption, while <a href=\"https:\/\/kotlinlang.org\/docs\/serialization.html\" target=\"_blank\" rel=\"noopener\">kotlinx.serialization<\/a> converts data to formats like JSON, and <a href=\"https:\/\/square.github.io\/okio\/\" target=\"_blank\" rel=\"noopener\">Okio<\/a> manages essential file I\/O. Additionally, <a href=\"https:\/\/skie.touchlab.co\/\" target=\"_blank\" rel=\"noopener\">SKIE<\/a> facilitates the use of modern types and coroutines on iOS, and <a href=\"https:\/\/cocoapods.org\/\" target=\"_blank\" rel=\"noopener\">CocoaPods<\/a> integration enables the use of iOS-specific dependencies.\n<\/p>\n<p>\nWe&#8217;ve worked with JetBrains and the Kotlin developer community to add Kotlin Multiplatform support to a number of Jetpack libraries and in some cases provide the iOS platform targets, while in others, JetBrains and the community provide the multiplatform distributions.\n<\/p>\n<p>\nToday, the Annotations, Collections, and DataStore libraries all have support for Kotlin Multiplatform in stable versions. We are also adding support to validate binary compatibility for the iOS platform targets, bringing them on a par with the quality standards for Android. In addition to the libraries above, we&#8217;ve also begun working on Kotlin Multiplatform support for <a href=\"https:\/\/developer.android.com\/kotlin\/multiplatform\/room\" target=\"_blank\" rel=\"noopener\">Room<\/a>, Lifecycle, and ViewModels with alpha versions now available. To better understand which classes and functions are available where, the library <a href=\"https:\/\/developer.android.com\/reference\/kotlin\/androidx\/collection\/package-summary\" target=\"_blank\" rel=\"noopener\">reference documentation<\/a> now indicates &#8220;common&#8221; and platform support.\n<\/p>\n<div class=\"separator\" style=\"clear: both;\"><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEh7S0CEVMRfrsVshYB_BYPiTNmfGiHBfUQXN5fY1JTAXwNwYo_bF1SnUGlw7ZmZ3L9EoM2DjHbHiBLo4kY78aomUT8perVMXBp-bMfDwiJ303kPI1MX-G5rocJSVfLhfP49YsYw166vaBMBwXazQyyKrx0ksym1rJXEuobymiutxeOkEzeWW5ny4Pw718k\/s1600\/image3.png\" style=\"display: block; padding: 1em 0px; text-align: center;\"><img decoding=\"async\" alt=\"Indication of Common, Native and Android support in documentation\" border=\"0\" data-original-height=\"959\" data-original-width=\"1999\" height=\"307\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEh7S0CEVMRfrsVshYB_BYPiTNmfGiHBfUQXN5fY1JTAXwNwYo_bF1SnUGlw7ZmZ3L9EoM2DjHbHiBLo4kY78aomUT8perVMXBp-bMfDwiJ303kPI1MX-G5rocJSVfLhfP49YsYw166vaBMBwXazQyyKrx0ksym1rJXEuobymiutxeOkEzeWW5ny4Pw718k\/s1600\/image3.png\" width=\"640\"\/><\/a><\/div>\n<p><i><\/p>\n<p><i>Indication of Common, Native and Android support in documentation<\/i><\/p>\n<p><\/i><\/p>\n<p>\nAndroid engineers have collaborated with JetBrains on the Kotlin compiler to improve runtime performance in Kotlin\/Native (for iOS &amp; native desktop operating systems), showing 18% runtime performance improvements in compiler benchmarks.  In addition the Android team contributed to build time performance improvements for the Kotlin Native Compiler of up to 2x speed ups.\n<\/p>\n<p>\nThe Android Gradle Plugin now has official support for Kotlin Multiplatform, enabling a concise build definition for setting up Android as a platform target for shared code as shown below:\n<\/p>\n<div style=\"background: rgb(255, 255, 255); border: 0px; overflow: auto; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0px;\"><span style=\"font-family: courier;\">plugins {\n    id(<span>\"org.jetbrains.kotlin.multiplatform\"<\/span>)\n    id(<span>\"com.android.library\"<\/span>)\n}\n\nkotlin {\n    androidTarget {\n        compilations.all {\n            kotlinOptions {\n                jvmTarget = <span>\"11\"<\/span>\n            }\n        }\n    }  \n    listOf(\n        iosX64(),\n        iosArm64(),\n        iosSimulatorArm64()\n    ).forEach { iosTarget -&gt;\n        iosTarget.binaries.framework {\n            baseName = <span>\"Shared\"<\/span>\n            isStatic = <span style=\"font-weight: bold;\">true<\/span>\n        }\n    }    \n    sourceSets {\n        commonMain.dependencies {\n            <span>\/\/ put your Multiplatform dependencies here<\/span>\n        }\n    }\n}<\/span>\n<\/pre>\n<\/div>\n<p><i><\/p>\n<p><i>KMP Support in the Android Gradle Plugin DSL<\/i><\/p>\n<p><\/i><\/p>\n<p>\nAs Android Studio is based on the IntelliJ Platform from JetBrains, it inherits support for Kotlin Multiplatform code editing and many other development features. Other Android development tools like Android Lint and Kotlin Symbol Processing (KSP) are also beginning to add more Kotlin Multiplatform support as well.\n<\/p>\n<p>\nGoogle Chrome now has official support for <a href=\"https:\/\/developer.chrome.com\/blog\/wasmgc\/\" target=\"_blank\" rel=\"noopener\">WasmGC<\/a> which is used by Kotlin Multiplatform&#8217;s WebAssembly platform target to enable code sharing with the browser in an efficient and performant way.\n<\/p>\n<p>\nLatest details on these projects are available on the updated <a href=\"http:\/\/developer.android.com\/kotlin\/multiplatform\" target=\"_blank\" rel=\"noopener\">Android Kotlin Multiplatform page<\/a>.\n<\/p>\n<h3>Future Areas of Work<\/h3>\n<p>\nWe&#8217;ve heard from many Android developers and Google engineering teams that they want expanded support for Kotlin Multiplatform so they can more easily share code with other platforms.  Android plans to continue collaborating with JetBrains, Google engineering teams, and the community on a variety of projects, including:\n<\/p>\n<ul>\n<ul>\n<li>Expanding and stabilizing Jetpack libraries with Kotlin Multiplatform support\n<\/li>\n<li>Wasm platform target support in Jetpack libraries\n<\/li>\n<li>Kotlin\/Native build performance\n<\/li>\n<li>Kotlin\/Native debugging\n<\/li>\n<li>Expanding Kotlin Multiplatform support in Android Studio\n  <\/li>\n<\/ul>\n<\/ul>\n<h3>Learn More and Try It Out<\/h3>\n<p>\nSharing code with Kotlin Multiplatform between Android and other platforms enables higher developer productivity and quality so we hope you will give it a try!  You can use the <a href=\"https:\/\/kmp.jetbrains.com\/?_gl=1*5pa7yg*_ga*NjYyMTIyNjYzLjE2NDYxNzI4MTQ.*_ga_9J976DJZ68*MTcxMjI2ODc4MC42OC4xLjE3MTIyNjkxMzQuNTAuMC4w&amp;_ga=2.19854524.527082860.1712264637-662122663.1646172814\" target=\"_blank\" rel=\"noopener\">Kotlin Multiplatform wizard<\/a> to create a new KMP project.  Learn more in the <a href=\"http:\/\/developer.android.com\/kotlin\/multiplatform\" target=\"_blank\" rel=\"noopener\">documentation<\/a>.\n<\/p>\n<p>\nAlternatively, explore one of these sample projects showcasing how to use some of the Jetpack libraries with Kotlin Multiplatform:\n<\/p>\n<p>\nIf there are additional areas you would like Android to work on <a href=\"https:\/\/issuetracker.google.com\/issues\/new?component=1337890&amp;template=1803002\" target=\"_blank\" rel=\"noopener\">let us know<\/a> and also be a part of our vibrant Android Developer community on <a href=\"https:\/\/www.linkedin.com\/showcase\/androiddev\/posts\/?feedView=all\" target=\"_blank\" rel=\"noopener\">LinkedIn<\/a>, <a href=\"https:\/\/medium.com\/androiddevelopers\">Medium<\/a>, <a href=\"https:\/\/www.youtube.com\/c\/AndroidDevelopers\/videos\" target=\"_blank\" rel=\"noopener\">YouTube<\/a>, and <a href=\"https:\/\/twitter.com\/AndroidDev\" target=\"_blank\" rel=\"noopener\">X<\/a>.\n<\/p>\n<\/div>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><br \/>\n<br \/>[ad_2]<br \/>\n<br \/><a href=\"http:\/\/android-developers.googleblog.com\/2024\/05\/android-support-for-kotlin-multiplatform-to-share-business-logic-across-mobile-web-server-desktop.html\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Posted by Maru Ahues Bouza \u2013 Director, Product Management, and Jeffrey van Gogh \u2013 Director, Engineering Traditionally, developers must either write code individually for<\/p>\n","protected":false},"author":1,"featured_media":232538,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[146],"tags":[],"_links":{"self":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/232537"}],"collection":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/comments?post=232537"}],"version-history":[{"count":0,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/232537\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media\/232538"}],"wp:attachment":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media?parent=232537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/categories?post=232537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/tags?post=232537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}