Adetunji Dahunsi

2024 App Development Year In Review: Android Jetpack Goes Multiplatform with Kotlin

Getting closer to write once, run anywhere for multiplatform apps

TJ Dahunsi

Dec 25 2024 · 3 min read

This year has been a great one for Android development with Jetpack libraries, for both the data and UI layers, but also app development in general when viewed from a multiplatform lens. It's never been easier to fetch, persist, retrieve and render app data for user interaction natively with one codebase on multiple platforms.

The following is a rundown of my favorite Android Jetpack releases in 2024, in order of architectural layer:

A Native Multiplatform Data Layer

  • Room goes Multiplatform: As of version 2.7.0-alpha01, Room now supports Android, desktop, and iOS—a huge win for persistent data storage across platforms!
  • Datastore adds KMP Support: Starting with version 1.1.0, Datastore also joined the multiplatform club, supporting the same platforms as Room.

A Native Multiplatform UI Layer

  • Lifecycle and ViewModel go Multiplatform: Versions 2.8.7 and up (including 2.9 alphas) made the essential Lifecycle and ViewModel concepts multiplatform, with implementations for Android, desktop, and iOS. This provides a platform agnostic starting point to defining:
    • What an app's UI layer is.
    • How it produces state for that UI.
    • When it can produce state for that UI.
    • How it should start, pause, resume, stop and terminate state production for a component that has a lifecycle. This scoping is crucial for performance in apps, especially for how resource intensive modern apps can be.
  • Navigation Compose benefits: These Lifecycle and ViewModel updates are particularly beneficial if you're using Navigation Compose or writing your own navigation that leverages existing lifecycle concepts. I'm particularly interested in the latter, as I'm currently playing around with what it means for an app to adapt to large screens.

A multiplatform UI Toolkit with Jetpack Compose

  • Multiplatform Drag-and-Drop: Drag-and-drop support landed for bothAndroid (1.6.0) and Desktop (1.7.0) — with each handling semantics for each platform with aplomb. In the case of the former, it also allows for receiving rich content in text fields using the Modifier.contentReceiver API.
  • Multiplatform Shapes: The Shapes library is now multiplatform as of version 1.0.0-alpha04, which allows for the morphing and animation between arbitrary shapes which can create a delightful app experience.
  • Shared Element Transitions: Starting with version 1.7.0, Compose now supports shared element transitions, adding visual flair to your multi platform apps. Earlier this year, I gave a talk at DroidCon NYC 2024 on how the APIs can be combined with the movableContentOf API to create truly immersive media experiences.

Real-World Testing with Heron

To truly see the potential of these updates, I've been building Heron, an open-source Bluesky client using Compose Multiplatform that is modeled after the Crane material design study. It's been amazing to see how far Kotlin (released 2016), Coroutines (released 2017), and Compose (released in 2020) have come. The app uses:

  • In the data layer:
    • Datastore with okio to persist auth tokens, and app navigation to disk.
    • Room to save posts, and other at-proto types to provide an offline first experience.
  • In the UI layer:
    • Lifecycle for each navigation destination, along with a ViewModel to manage state production for it.
    • The shapes graphics library for creating user avatars in threaded responses, UI motif of a timeline with "mass" The timeline of threaded replies distort otherwise circular avatars song where they are closest to the timeline.
    • Shared element transitions when performing diving into posts for a sense of placement in the app.
    • There are plans for using the drag and drop APIs for the uploading of media to the platform.

This allows me to build the following UI on Android, desktop and iOS:

imageimageimage
Splash screen with app logo shared elementShape morphing on avatar from timeline to threadShared elements on thread diving

The more I build, the more excited I am for the future of app development. I think this is the closest the industry has come to truly native "write once, run anywhere".

Heron can be found at the github repository link below.

17