# Migrating a Real Android App to Kotlin Multiplatform 3/4 -- Sharing the UI without losing safety net

DevFeed: [Migrating a Real Android App to Kotlin Multiplatform 3/4 -- Sharing the UI without losing safety net](<https://devfeed.tech/articles/migrating-a-real-android-app-to-kotlin-multiplatform-3-4-sharing-the-ui-without-losing-safety-net-124797.md>)

Original publisher: [Read original article](<https://proandroiddev.com/migrating-a-real-android-app-to-kotlin-multiplatform-3-4-sharing-the-ui-without-losing-safety-net-f74a6bf408ae?source=rss----c72404660798---4>)

Author: Daniel Voko

Published: 2026-11-09T14:53:26Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [compose-multiplatform](<https://devfeed.tech/topics/compose-multiplatform.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [robolectric](<https://devfeed.tech/topics/robolectric.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [2](<https://devfeed.tech/tags/2.md>), [about](<https://devfeed.tech/tags/about.md>), [all](<https://devfeed.tech/tags/all.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-library](<https://devfeed.tech/tags/android-library.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [animation](<https://devfeed.tech/tags/animation.md>), [app](<https://devfeed.tech/tags/app.md>), [application](<https://devfeed.tech/tags/application.md>), [article](<https://devfeed.tech/tags/article.md>), [away](<https://devfeed.tech/tags/away.md>), [build](<https://devfeed.tech/tags/build.md>), [classes](<https://devfeed.tech/tags/classes.md>), [code](<https://devfeed.tech/tags/code.md>), [code-smell](<https://devfeed.tech/tags/code-smell.md>), [compose-multiplatform](<https://devfeed.tech/tags/compose-multiplatform.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [safety](<https://devfeed.tech/tags/safety.md>), [sharing](<https://devfeed.tech/tags/sharing.md>), [ui](<https://devfeed.tech/tags/ui.md>)

## AI overview

Most BikeHub composables moved to Kotlin Multiplatform's commonMain with few code changes; the harder work was adapting Android-centered tooling. The author had first moved UI state and logic into plain Kotlin through Ouroboros-Compose, avoiding Android ViewModel dependencies across 38 feature modules. Android-specific seams were limited and isolated behind expect/actual or an ExternalNavigator interface. Of 13,843 androidMain lines, 9,653 were previews; Compose Preview Screenshot Testing did not work in a KMP module, so the project uses Roborazzi under Robolectric in androidHostTest. A convention plugin enables screenshot tests across 40 modules and copies centralized Compose Multiplatform resources into host-test assets, relying on a reflective workaround to expose their generated location. The setup checks Android rendering only, leaves iOS and web unverified, and stores 55 MB of PNG baselines; half-scale captures limit their size. The account emphasizes auditing previews, resources, plugins and tests before changing module types.

## Source excerpt

Migrating a Real Android App to Kotlin MultiplatformPart 3: Sharing the UI without losing the safety net Part 2 ended on a pattern: the code that moved most easily was the code that knew nothing about Android. By that logic the UI layer should have been the worst part of the migration. It touches the screen, the system bars, the keyboard, the back gesture -- everything that is unmistakably a platform. And, much to my amazement, it wasn't. The composables moved about as easily as the domain models did. What didn't move was everything around them. The resource system, the build plugins, the preview tooling and the screenshot tests were all built on the assumption that a Compose module is an Android library module. Once that stopped being true, the application code was fine and the ecosystem around it wasn't. Sharing application code turned out to be easier than sharing the ecosystem around it. That's the whole article. What moved easily Most composables moved to commonMain unchanged. Layout, state, theming, animation -- Compose Multiplatform covers the surface BikeHub uses, and the diff for a typical screen was mostly imports. Two things made this smoother than it would otherwise have been. The UDF layer went first. Every feature module in BikeHub uses Ouroboros-Compose, a small unidirectional-data-flow library (influenced by Spotify's Mobius, that I used back then, when views and fragments ruled the android UI). It abstracts the ViewModel away and keeps the UI logic in plain, testable classes. I refactored it to KMP as step 0 of the whole migration, before touching a single feature module. That ordering mattered more than it looks. Because the UI logic doesn't sit inside an Android ViewModel, there was no androidx.lifecycle dependency threaded through 38 feature modules waiting to be unpicked. The state holders were already just Kotlin. Android platform code in the UI layer was already a code smell. I'd treated it that way for years, so there wasn't much of it to find.