<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: El</title>
    <description>The latest articles on DEV Community by El (@2bab).</description>
    <link>https://dev.to/2bab</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F610100%2Ff74946fd-b05e-4c4f-88c5-b866c756a3b9.png</url>
      <title>DEV Community: El</title>
      <link>https://dev.to/2bab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/2bab"/>
    <language>en</language>
    <item>
      <title>Migrating Google's A2UI Compose Renderer to Kotlin Multiplatform</title>
      <dc:creator>El</dc:creator>
      <pubDate>Sun, 29 Nov 2026 03:17:23 +0000</pubDate>
      <link>https://dev.to/2bab/migrating-googles-a2ui-compose-renderer-to-kotlin-multiplatform-54bd</link>
      <guid>https://dev.to/2bab/migrating-googles-a2ui-compose-renderer-to-kotlin-multiplatform-54bd</guid>
      <description>&lt;p&gt;I spent nearly an hour chatting with Nick and Anton from the A2UI Compose team at Android Dev Summit 2026. The month before, they had released 1.0.0-alpha02 of their &lt;a href="https://developer.android.com/develop/ui/compose/agentic" rel="noopener noreferrer"&gt;Agent-to-UI renderer for Jetpack Compose&lt;/a&gt; (&lt;a href="https://a2ui.org" rel="noopener noreferrer"&gt;A2UI&lt;/a&gt;), but the official &lt;code&gt;androidx.a2ui:*&lt;/code&gt; and &lt;code&gt;androidx.compose.material3:material3-a2ui&lt;/code&gt; artifacts only target Android. Answering audience questions at the event, they mentioned several times that KMP / CMP support isn't a near-term priority. I noticed at least two or three other developers walk up to ask about KMP as well. Since I had already written a deep dive on &lt;a href="https://genui-field-notes.2bab.com/zh-cn/04-google-a2ui" rel="noopener noreferrer"&gt;Google A2UI&lt;/a&gt; in my minibook &lt;em&gt;GenUI Field Notes&lt;/em&gt;, I volunteered on the spot to handle the port and open-source it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F67nhgxvu64g3mklxdeir.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F67nhgxvu64g3mklxdeir.jpg" alt="Chatting with Nick and Anton from the A2UI Compose team at Android Dev Summit 2026" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of writing a third-party implementation from scratch, I built a migration pipeline directly on top of the official A2UI sources, ported them to Kotlin Multiplatform, and open-sourced &lt;a href="https://github.com/BinaryTape/a2ui-kmp" rel="noopener noreferrer"&gt;a2ui-kmp&lt;/a&gt;. On Android, Gradle Module Metadata redirects consumers straight to Google's official artifacts, so you run their unmodified code. On Desktop (JVM) and iOS, it compiles those same AOSP sources against a thin compatibility layer while keeping the original &lt;code&gt;androidx.a2ui.*&lt;/code&gt; package names and APIs intact.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faxblwe2llazeyxvgudok.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faxblwe2llazeyxvgudok.png" alt="a2ui-kmp rendering the same booking form and sending events back on macOS Desktop (left) and the iOS Simulator (right)" width="800" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The booking form above runs the exact same A2UI message stream handling and outbound event logic in &lt;code&gt;commonMain&lt;/code&gt; across macOS Desktop and the iOS Simulator.&lt;/p&gt;

&lt;p&gt;Scoping out the codebase showed that the platform gaps came down to fewer than ten categories, and two-thirds of the upstream source files didn't need a single edit. That let me focus on the architecture and engineering boundaries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Splitting packages cleanly so scripts manage synced upstream files while AI-written compatibility code lives in its own module;&lt;/li&gt;
&lt;li&gt;Sharing a single dependency version catalog across subprojects, and wiring the Kotlin 2.3 and 2.4 builds together with &lt;code&gt;includeBuild&lt;/code&gt; in a Composite Build so the repo works out of the box in the IDE;&lt;/li&gt;
&lt;li&gt;Verifying the multiplatform compatibility layer against ground-truth output recorded from the official Jetpack Compose release.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff0e5qvlf6c0p0wcfp0vm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff0e5qvlf6c0p0wcfp0vm.jpeg" alt="Initial AI analysis of the multiplatform migration surface across A2UI modules" width="776" height="1316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, let's look at how to add the library to your project. Then I'll walk through the architectural trade-offs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Start
&lt;/h2&gt;

&lt;p&gt;Adding &lt;code&gt;a2ui-kmp&lt;/code&gt; to a KMP project starts with one key version constraint. The official Jetpack Compose release of A2UI depends on the latest Compose alpha and compiles with Kotlin 2.4. Gradle upgrades Compose and &lt;code&gt;kotlin-stdlib&lt;/code&gt; in the host app to the minimum versions required by its dependencies, &lt;strong&gt;but an older Kotlin compiler cannot read an iOS klib produced by a newer compiler&lt;/strong&gt;. Because the klib ABI isn't backward-compatible, we split the modules into two tiers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The 5 core packages (&lt;code&gt;a2ui-model&lt;/code&gt;, &lt;code&gt;a2ui-engine&lt;/code&gt;, &lt;code&gt;compose-runtime&lt;/code&gt;, &lt;code&gt;compose-ui&lt;/code&gt;, &lt;code&gt;compose-ui-testing&lt;/code&gt;) are built with Kotlin 2.3.21 and Compose Multiplatform 1.12.2 (Compose runtime 1.12.1). Because none of them require Kotlin 2.4, &lt;strong&gt;iOS apps on Kotlin 2.3 or newer can use them right away&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;material3-a2ui&lt;/code&gt; is built with Kotlin 2.4.0 and Compose Multiplatform 1.13.0-beta01, because upstream uses Material 3 APIs that only landed in CMP 1.13 (more on why in the Build Architecture section below). We'll move it to stable CMP 1.13 once that ships.&lt;/li&gt;
&lt;li&gt;On Android, dependencies resolve directly to Google's official 1.0.0-alpha02 artifacts and inherit the upstream requirements: compileSdk 37 when using &lt;code&gt;a2ui-model&lt;/code&gt; / &lt;code&gt;a2ui-engine&lt;/code&gt; alone; compileSdk 37.1 and Jetpack Compose 1.13.0-alpha03 for &lt;code&gt;compose-runtime&lt;/code&gt; and above; and Material 3 1.5.0-alpha28 when using &lt;code&gt;material3-a2ui&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With those versions in place, add the modules you need to &lt;code&gt;gradle/libs.versions.toml&lt;/code&gt;. We recommend adding a &lt;code&gt;-kmp&lt;/code&gt; suffix to the catalog aliases to distinguish them from Google's Android-only coordinates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# gradle/libs.versions.toml
&lt;/span&gt;&lt;span class="k"&gt;[versions]&lt;/span&gt;
&lt;span class="na"&gt;a2ui&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"1.0.0-alpha02"&lt;/span&gt;

&lt;span class="k"&gt;[libraries]&lt;/span&gt;
&lt;span class="na"&gt;a2ui-material3-kmp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ai.littlepress.a2ui:material3-a2ui"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"a2ui"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="na"&gt;a2ui-compose-ui-kmp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ai.littlepress.a2ui:compose-ui"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"a2ui"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 6 published KMP artifacts map 1:1 to Google's official Android artifacts:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;
&lt;code&gt;ai.littlepress.a2ui:*&lt;/code&gt; Artifact&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;Android Resolution Target&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;a2ui-model&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Core data layer for app and component developers&lt;/td&gt;
&lt;td&gt;&lt;code&gt;androidx.a2ui:a2ui-model&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;a2ui-engine&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Message and data-binding engine for renderer authors (no Compose dependency)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;androidx.a2ui:a2ui-engine&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;compose-runtime&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Compose A2UI renderer runtime (state and data binding)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;androidx.a2ui.compose:compose-runtime&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;compose-ui&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Compose A2UI renderer and catalog API (without Material 3)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;androidx.a2ui.compose:compose-ui&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;compose-ui-testing&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Testing APIs for custom catalog components&lt;/td&gt;
&lt;td&gt;&lt;code&gt;androidx.a2ui.compose:compose-ui-testing&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;material3-a2ui&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Basic component catalog built on Compose Material 3&lt;/td&gt;
&lt;td&gt;&lt;code&gt;androidx.compose.material3:material3-a2ui&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most projects only need &lt;code&gt;a2ui-material3-kmp&lt;/code&gt; (to use the Material 3 Basic Catalog out of the box) or &lt;code&gt;a2ui-compose-ui-kmp&lt;/code&gt; (to build a custom component catalog), without worrying about the other four modules. The snippet below, taken from &lt;code&gt;samples/composeApp/src/commonMain/kotlin/sample/material3/A2ui.kt&lt;/code&gt; and &lt;code&gt;FormSample.kt&lt;/code&gt;, shows how to initialize &lt;code&gt;A2uiMessageProcessor&lt;/code&gt;, feed it agent messages, and collect user interaction events in &lt;code&gt;commonMain&lt;/code&gt;. Since the sample agent doesn't send images, video, or audio, those three callbacks are no-ops; a real app plugs in its own image loader and media players there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;littlepress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a2ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;android&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;androidx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a2ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;runtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;A2uiMessageParser&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;androidx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a2ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;A2uiMessageProcessor&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;androidx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a2ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;A2uiBasicCatalogV1&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;androidx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a2ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;A2uiMessageProcessor&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;androidx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a2ui&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;processInput&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;androidx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;foundation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Arrangement&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;rememberA2uiProcessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;A2uiMessageProcessor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;remember&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;catalog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;materialA2uiBasicCatalogV1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="c1"&gt;// The sample's agent sends no images, video or audio, so these three&lt;/span&gt;
            &lt;span class="c1"&gt;// slots are empty; a real app plugs its image loader and players in here.&lt;/span&gt;
            &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MaterialA2uiBasicCatalogV1Defaults&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;video&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MaterialA2uiBasicCatalogV1Defaults&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;video&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;audioPlayer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MaterialA2uiBasicCatalogV1Defaults&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;audioPlayer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;functions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;A2uiBasicCatalogV1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Functions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// ①&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nc"&gt;A2uiMessageProcessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;catalogs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;listOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nc"&gt;LaunchedEffect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;withContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Dispatchers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collectMessages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nc"&gt;A2uiSurfaces&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;A2uiMessageProcessor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;modifier&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Modifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Modifier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;surfaces&lt;/span&gt; &lt;span class="n"&gt;by&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;activeSurfaces&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collectAsState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;modifier&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verticalArrangement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Arrangement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;spacedBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;surfaces&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forEach&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;surface&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;surface&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;A2uiSurface&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;surface&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Composable&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nc"&gt;FormScreen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;incomingJsonLines&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onSendToAgent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;rememberA2uiProcessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nc"&gt;LaunchedEffect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;A2uiMessageParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;incomingJsonLines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forEach&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;processInput&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;outboundEvents&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;collect&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;onSendToAgent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nc"&gt;A2uiSurfaces&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;rememberA2uiProcessor()&lt;/code&gt; creates a message processor wired to the Material 3 Basic Catalog and continuously consumes its message queue on a background coroutine. &lt;code&gt;FormScreen&lt;/code&gt; feeds incoming JSON lines from the agent into &lt;code&gt;processor&lt;/code&gt; and collects form submission events from &lt;code&gt;outboundEvents&lt;/code&gt;. If you look closely at the imports, you'll notice two &lt;code&gt;A2uiMessageProcessor&lt;/code&gt; symbols: one is the top-level factory function in &lt;code&gt;compose.ui&lt;/code&gt;, and the other is the interface in &lt;code&gt;model.processor&lt;/code&gt;, which is how upstream designed it.&lt;/p&gt;

&lt;p&gt;Calling A2UI from &lt;code&gt;commonMain&lt;/code&gt; differs from Android code in just two small spots:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Two upstream public interface methods take &lt;code&gt;java.util.Locale&lt;/code&gt; in their signatures; in &lt;code&gt;commonMain&lt;/code&gt;, they use &lt;code&gt;ai.littlepress.a2ui.compat.java.util.Locale&lt;/code&gt; instead (a typealias to &lt;code&gt;java.util.Locale&lt;/code&gt; on JVM and Android).&lt;/li&gt;
&lt;li&gt;At ①, &lt;code&gt;A2uiBasicCatalogV1.Functions(context)&lt;/code&gt; takes an &lt;code&gt;android.content.Context&lt;/code&gt; on Android, whereas on Desktop and iOS you pass &lt;code&gt;ai.littlepress.a2ui.compat.android.content.Context()&lt;/code&gt; (which delegates to the host OS browser to open URLs).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Source Migration Architecture
&lt;/h2&gt;

&lt;p&gt;Keeping Google's original package names and public APIs intact means handling the JDK and Android types they depend on underneath. Across the 193 &lt;code&gt;.kt&lt;/code&gt; files in the 6 upstream modules, the Compose UI rendering code barely touches Android-specific APIs, but references to &lt;code&gt;java.util.Locale&lt;/code&gt;, &lt;code&gt;SimpleDateFormat&lt;/code&gt;, &lt;code&gt;NumberFormat&lt;/code&gt;, ICU &lt;code&gt;MessageFormat&lt;/code&gt;, &lt;code&gt;android.util.JsonReader&lt;/code&gt;, &lt;code&gt;android.content.res.Resources&lt;/code&gt;, and &lt;code&gt;ReentrantLock&lt;/code&gt; are scattered throughout the codebase.&lt;/p&gt;

&lt;p&gt;Before writing the code, design review and our early iterations helped us avoid two traps:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Platform APIs and Compatibility Layer
&lt;/h3&gt;

&lt;p&gt;Could we keep the &lt;code&gt;java.*&lt;/code&gt; package names as-is? We considered declaring &lt;code&gt;package java.util&lt;/code&gt; in &lt;code&gt;iosMain&lt;/code&gt; for a custom &lt;code&gt;Locale&lt;/code&gt; so we wouldn't even have to touch upstream imports. That falls apart in a multiplatform setup. Because two upstream public interfaces expose &lt;code&gt;java.util.Locale&lt;/code&gt; in their method signatures, the type has to live in &lt;code&gt;commonMain&lt;/code&gt;. On the JVM, the classloader rejects any user-defined &lt;code&gt;java.*&lt;/code&gt; package at load time (&lt;code&gt;SecurityException: Prohibited package name&lt;/code&gt;) and collides with the JDK's built-in classes. Putting all shims under &lt;code&gt;ai.littlepress.a2ui.compat.*&lt;/code&gt; and rewriting imports by rule solved both problems cleanly.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Upstream Sync and Directory Layering
&lt;/h3&gt;

&lt;p&gt;The second question was how to sync upstream code and structure the repo so upstream snapshots and our own code stay separate. We didn't need to mirror AOSP's internal build workflow. Pulling the latest release head directly from the AOSP git repository, including its tests and resource directories, was enough. Separating the upstream and downstream directories let us enforce a strict rule: &lt;strong&gt;scripts handle all upstream syncing and mechanical rewrites, while multiplatform compatibility code lives in its own module, written with AI assistance and verified through review and testing&lt;/strong&gt;. The repository is structured around that split:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a2ui-kmp/
├── source/                  # read-only upstream snapshot
│   ├── UPSTREAM             # the AOSP commit it came from
│   ├── a2ui/
│   └── material3-a2ui/
├── target/
│   ├── build-logic/         # source + overlays -&amp;gt; commonMain
│   ├── a2ui-kmp/            # Kotlin 2.3 build: 5 core packages
│   │   ├── a2ui-compat/     # hand-written compatibility layer
│   │   ├── a2ui-model/
│   │   │   ├── overlay-generated/      # rule-based rewrites
│   │   │   └── overlay-generated.json  # rules + sha256
│   │   ├── a2ui-engine/
│   │   └── compose/
│   └── material3-a2ui-kmp/  # Kotlin 2.4 build: material3-a2ui
│       ├── overlay-generated/
│       ├── overlay-manual/  # hand-written (one file today)
│       └── resources-generated/  # generated translations
├── tests/integration/       # tests against published artifacts
├── samples/
└── scripts/                 # sync, rewrite, verify, record
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Overlay Replacement and Change Verification
&lt;/h3&gt;

&lt;p&gt;The files compiled into &lt;code&gt;commonMain&lt;/code&gt; fall into five layers, each maintained in only one way:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;source/&lt;/code&gt; (read-only AOSP snapshot, managed by &lt;code&gt;sync-upstream.py&lt;/code&gt;): Pulls &lt;code&gt;source/a2ui/&lt;/code&gt; and &lt;code&gt;source/material3-a2ui/&lt;/code&gt; at the AOSP commit pinned in &lt;code&gt;source/UPSTREAM&lt;/code&gt; for &lt;code&gt;androidx.a2ui&lt;/code&gt; 1.0.0-alpha02, verified file-by-file in CI by &lt;code&gt;check-upstream.py&lt;/code&gt;. Out of 193 upstream &lt;code&gt;.kt&lt;/code&gt; files, 124 compile as-is without a single line changed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;target/*/overlay-generated/&lt;/code&gt; (rule-based rewrites, managed by &lt;code&gt;generate-overlays.py&lt;/code&gt;): Of the remaining 69 files that touch platform APIs, 68 only need deterministic mechanical rewrites, mostly repointing &lt;code&gt;java.*&lt;/code&gt; / &lt;code&gt;android.*&lt;/code&gt; imports to &lt;code&gt;ai.littlepress.a2ui.compat.*&lt;/code&gt; and replacing &lt;code&gt;Locale.US&lt;/code&gt; constants and &lt;code&gt;::class.java.simpleName&lt;/code&gt;. Each module's &lt;code&gt;overlay-generated.json&lt;/code&gt; records the applied rule names and the upstream file's sha256, and &lt;a href="https://github.com/BinaryTape/a2ui-kmp/blob/main/DEVELOPMENT.md" rel="noopener noreferrer"&gt;DEVELOPMENT.md&lt;/a&gt; lists the full rule table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;target/*/overlay-manual/&lt;/code&gt; (hand-maintained replacements, verified by &lt;code&gt;overlay-manual.json&lt;/code&gt;): If a file needs even a one-line logic change beyond the fixed rewrite rules, it isn't allowed in &lt;code&gt;overlay-generated/&lt;/code&gt; and must go into &lt;code&gt;overlay-manual/&lt;/code&gt;. Across all 193 source files in the repo, &lt;strong&gt;only one file sits here today: &lt;code&gt;ShimmerIndicator.kt&lt;/code&gt;&lt;/strong&gt;. On Android, the original implementation mutates the same shader's &lt;code&gt;localMatrix&lt;/code&gt; every animation frame; on Desktop and iOS, Skia shaders are immutable once created, so we recreate the &lt;code&gt;RadialGradientShader&lt;/code&gt; each frame with the current offset and radius.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;target/a2ui-kmp/a2ui-compat/&lt;/code&gt; and each module's own &lt;code&gt;src/&lt;/code&gt; (compatibility layer, maintained separately): Implements &lt;code&gt;Locale&lt;/code&gt;, ICU &lt;code&gt;MessageFormat&lt;/code&gt;, CLDR 45 plural rules, date/number/currency formatting, a strict &lt;code&gt;JsonReader&lt;/code&gt;, and a FIFO-fair &lt;code&gt;ReentrantLock&lt;/code&gt; on iOS. Everything here lives under &lt;code&gt;ai.littlepress.a2ui.compat.*&lt;/code&gt; without touching upstream directories.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;resources-generated/&lt;/code&gt; and recorded reference fixtures (generated or recorded by script, never edited by hand): Localized strings in &lt;code&gt;material3-a2ui&lt;/code&gt; (85 locales, 11 strings each), for example, are generated from upstream's &lt;code&gt;res/values*/strings.xml&lt;/code&gt; into &lt;code&gt;target/material3-a2ui-kmp/resources-generated/&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;upstreamSources(...)&lt;/code&gt; in &lt;code&gt;target/build-logic&lt;/code&gt; wires all of this together for the compiler: it adds &lt;code&gt;source/&lt;/code&gt; to &lt;code&gt;commonMain&lt;/code&gt;, excludes any relative paths present in the two overlay directories, and splices in the overlay files.&lt;/p&gt;

&lt;p&gt;If Google modifies an overlaid file in a future upstream release, the sha256 check in the manifest fails immediately during the build and points straight to the changed file. For day-to-day code reviews, we can focus on the hand-written code (&lt;code&gt;overlay-manual/&lt;/code&gt; and &lt;code&gt;a2ui-compat/&lt;/code&gt;) and architectural changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build Architecture
&lt;/h2&gt;

&lt;p&gt;The Gradle build setup went through just as much iteration as the source layering.&lt;/p&gt;

&lt;p&gt;Because &lt;code&gt;material3-a2ui&lt;/code&gt; and the 5 core packages underneath require different Kotlin and Compose Multiplatform versions, the repo has to be split into two separate Gradle builds. In the coding agent's first attempt, dependency versions were scattered across &lt;code&gt;gradle.properties&lt;/code&gt;, and the material3 build reached into the other build's &lt;code&gt;buildSrc&lt;/code&gt; via &lt;code&gt;srcDir&lt;/code&gt;. Worse, for &lt;code&gt;samples/&lt;/code&gt; to depend on the local libraries, the initial proposal required running a CLI publish task before you could even open the project in the IDE for the first time.&lt;/p&gt;

&lt;p&gt;That kind of Gradle duct tape is painful to look at. Even if humans rarely touch the build scripts by hand, a fragile setup like that is just as hard for AI agents to maintain without breaking things. Drawing on the Composite Build patterns from Section 2-1 of my book &lt;a href="https://eab.2bab.com/doc/02/2-1-Gradle-Project-Structure#_2-1-3-composite-build" rel="noopener noreferrer"&gt;&lt;em&gt;Extending Android Builds&lt;/em&gt;&lt;/a&gt;, we refactored the build into the structure below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F2bab-images.lastmayday.com%2Fgradle-build-architecture.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F2bab-images.lastmayday.com%2Fgradle-build-architecture.svg" alt="a2ui-kmp Gradle build topology and dual-path verification architecture" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is how the three key pieces of this build fit together.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. A Single Root Version Catalog Shared Across Builds
&lt;/h3&gt;

&lt;p&gt;Maintaining multiple standalone Gradle builds in one repo often leads to duplicated versions across &lt;code&gt;gradle.properties&lt;/code&gt; files or the overhead of an internal BOM. Instead, we keep a single &lt;code&gt;gradle/libs.versions.toml&lt;/code&gt; at the repo root (with comments noting which versions come from upstream 1.0.0-alpha02 and why others were bumped), and point &lt;code&gt;target/a2ui-kmp&lt;/code&gt;, &lt;code&gt;target/material3-a2ui-kmp&lt;/code&gt;, &lt;code&gt;target/build-logic&lt;/code&gt;, and &lt;code&gt;tests/integration&lt;/code&gt; at that same file via &lt;code&gt;from(files(...))&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// target/a2ui-kmp/settings.gradle.kts&lt;/span&gt;
&lt;span class="n"&gt;dependencyResolutionManagement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;versionCatalogs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"libs"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;files&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"../../gradle/libs.versions.toml"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only exception is &lt;code&gt;samples/&lt;/code&gt;: it keeps its own standalone &lt;code&gt;samples/gradle/libs.versions.toml&lt;/code&gt; so the sample project can be copied out directly as a self-contained starter template.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Dual Kotlin 2.3 / 2.4 Builds &amp;amp; Replacing &lt;code&gt;buildSrc&lt;/code&gt; with &lt;code&gt;build-logic&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Why not just bump all 6 modules to Kotlin 2.4 and compile everything in a single Gradle build?&lt;/p&gt;

&lt;p&gt;It comes down to iOS klib ABI compatibility. Upstream &lt;code&gt;material3-a2ui&lt;/code&gt; uses &lt;code&gt;MaterialTheme.motionScheme&lt;/code&gt;, the new Slider and ExposedDropdownMenu overloads, &lt;code&gt;TimePickerState.isInputValid&lt;/code&gt;, and other APIs that only landed in Compose Multiplatform 1.13.0-beta01, whose iOS klib is compiled with Kotlin 2.4.0. Because an older Kotlin compiler cannot read an iOS klib with a newer ABI version, &lt;code&gt;material3-a2ui&lt;/code&gt; has to be compiled with Kotlin 2.4.0.&lt;/p&gt;

&lt;p&gt;On the flip side, if we also compiled the 5 core packages with Kotlin 2.4.0, &lt;strong&gt;any iOS app still on stable Kotlin 2.3 + CMP 1.12.2 that only needs the core renderer or a custom catalog&lt;/strong&gt; wouldn't be able to use them at all. Splitting &lt;code&gt;target/a2ui-kmp&lt;/code&gt; (Kotlin 2.3.21 + CMP 1.12.2) from &lt;code&gt;target/material3-a2ui-kmp&lt;/code&gt; (Kotlin 2.4.0 + CMP 1.13.0-beta01) keeps the 5 core packages compatible with Kotlin 2.3. During CLI builds, the core packages are published to the local &lt;code&gt;build/repo&lt;/code&gt; first so the material3 build can consume them, while both builds target Kotlin 2.2 for metadata and bytecode.&lt;/p&gt;

&lt;p&gt;To share convention plugins between two builds running different Kotlin versions, we replaced &lt;code&gt;buildSrc&lt;/code&gt; with a standalone &lt;code&gt;target/build-logic&lt;/code&gt; build and declared its plugin dependencies as &lt;code&gt;compileOnly&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// target/build-logic/build.gradle.kts&lt;/span&gt;
&lt;span class="n"&gt;plugins&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sb"&gt;`kotlin-dsl`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;dependencies&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;compileOnly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;libs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kotlin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gradlePlugin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;compileOnly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;libs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mavenPublish&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gradlePlugin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That way, &lt;code&gt;target/build-logic&lt;/code&gt; compiles against the Gradle plugin APIs without forcing a fixed Kotlin version onto either build's classpath. Each build brings its own Kotlin version while sharing the source-overlay logic and publishing configuration from &lt;code&gt;build-logic&lt;/code&gt; (which also patches the generated &lt;code&gt;.module&lt;/code&gt; metadata so Android consumers automatically resolve Google's official &lt;code&gt;androidx.a2ui&lt;/code&gt; artifacts).&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Root Composite Build and Why &lt;code&gt;tests/integration&lt;/code&gt; Stays Outside
&lt;/h3&gt;

&lt;p&gt;To make the repo work out of the box in Android Studio or IntelliJ IDEA, a root &lt;code&gt;settings.gradle.kts&lt;/code&gt; wires the development builds together into a Composite Build via &lt;code&gt;includeBuild&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// settings.gradle.kts&lt;/span&gt;
&lt;span class="n"&gt;rootProject&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"a2ui-kmp-repository"&lt;/span&gt;
&lt;span class="nf"&gt;includeBuild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"target/build-logic"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;includeBuild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"target/a2ui-kmp"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;includeBuild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"target/material3-a2ui-kmp"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;includeBuild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"samples"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Opening the repo root in the IDE lets Gradle automatically replace the &lt;code&gt;ai.littlepress.a2ui:*&lt;/code&gt; dependencies in &lt;code&gt;samples&lt;/code&gt; with the local source modules. Right after cloning, you can launch &lt;code&gt;samples&lt;/code&gt; without running any publish tasks first, and Cmd-click straight from sample code into the library sources to set breakpoints.&lt;/p&gt;

&lt;p&gt;Notice one deliberate omission in the root &lt;code&gt;settings.gradle.kts&lt;/code&gt; above: &lt;strong&gt;&lt;code&gt;tests/integration&lt;/code&gt; is not included via &lt;code&gt;includeBuild&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's intentional. &lt;strong&gt;A lot of critical metadata only exists in published Maven artifacts. If Gradle substitutes those dependencies with local source modules inside a Composite Build, you completely bypass what downstream apps actually consume.&lt;/strong&gt; For instance, a source-substituted build won't catch broken &lt;code&gt;.module&lt;/code&gt; forwarding to Google's Android artifacts, an unexpected iOS klib ABI version, or a missing transitive dependency. Instead, &lt;code&gt;tests/integration&lt;/code&gt; runs as a standalone build that resolves &lt;code&gt;ai.littlepress.a2ui&lt;/code&gt; exclusively from the freshly published local &lt;code&gt;../../build/repo&lt;/code&gt; directory using &lt;code&gt;exclusiveContent&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// tests/integration/settings.gradle.kts&lt;/span&gt;
&lt;span class="n"&gt;dependencyResolutionManagement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;repositories&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// ai.littlepress.a2ui comes from the artifacts just built only: a missing one fails.&lt;/span&gt;
        &lt;span class="n"&gt;exclusiveContent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;forRepository&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;maven&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"../../build/repo"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="n"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;includeGroup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ai.littlepress.a2ui"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nf"&gt;google&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;mavenCentral&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// The repository's one version catalog.&lt;/span&gt;
    &lt;span class="n"&gt;versionCatalogs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"libs"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;files&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"../../gradle/libs.versions.toml"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If even one artifact is missing from &lt;code&gt;build/repo&lt;/code&gt;, the build fails immediately instead of silently falling back to Maven Central. Our verification script runs &lt;code&gt;tests/integration&lt;/code&gt; twice: once with &lt;code&gt;-Pa2uiIntegration=minimum&lt;/code&gt; on Kotlin 2.3.21 to test the 5 core packages, and once with &lt;code&gt;-Pa2uiIntegration=all&lt;/code&gt; on Kotlin 2.4.0 to test all 6 packages including &lt;code&gt;material3-a2ui&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing and Behavioral Alignment: Recording Ground Truth from Android
&lt;/h2&gt;

&lt;p&gt;Locking down the source layers and build boundaries made splitting up the work across AI agents straightforward: one agent wrote the multiplatform compatibility code inside &lt;code&gt;a2ui-compat&lt;/code&gt;, a second agent reviewed it independently against the upstream sources, and I focused on architecture and acceptance criteria.&lt;/p&gt;

&lt;p&gt;The big question was: &lt;strong&gt;how do we know the AI-written &lt;code&gt;a2ui-compat&lt;/code&gt; code on Desktop and iOS actually behaves the same as Android?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our first instinct was to use &lt;code&gt;kotlinx-datetime&lt;/code&gt; for dates, delegate to &lt;code&gt;java.text.NumberFormat&lt;/code&gt; on the JVM, and call &lt;code&gt;Foundation.NSNumberFormatter&lt;/code&gt; on iOS. Digging into the edge cases during the second design review showed why that wouldn't hold up: &lt;strong&gt;the JDK's &lt;code&gt;java.text&lt;/code&gt; and Apple's &lt;code&gt;Foundation&lt;/code&gt; disagree with Android on plenty of cases out of the box&lt;/strong&gt;. JPY uses 0 decimal places on Android, for example, and the date pattern letter &lt;code&gt;u&lt;/code&gt; means day-of-week &lt;code&gt;1..7&lt;/code&gt; in Android's &lt;code&gt;SimpleDateFormat&lt;/code&gt; but extended year in Apple's ICU. Calling each platform's default formatters directly would guarantee subtle inconsistencies across platforms.&lt;/p&gt;

&lt;p&gt;To keep the tests from sharing the same blind spots as the implementation, we spun up an Android 15 emulator (API 35, ICU 75.1 / CLDR 45 / Unicode 15.1), &lt;strong&gt;recorded the actual output of the official Jetpack Compose release, and checked those recordings into &lt;code&gt;tests/integration&lt;/code&gt; as ground-truth fixtures for Desktop and iOS&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number and currency formatting: Checks number formatting across 50 locales along with currencies like JPY (0 decimals) and KWD (3 decimals). Desktop and iOS use the digit sets and AM/PM strings recorded from Android, while iOS follows ICU in outputting each locale's default CLDR numbering system, such as Arabic-Indic digits for Arabic.&lt;/li&gt;
&lt;li&gt;Plural rules and date formatting: Covers 836 ICU &lt;code&gt;MessageFormat&lt;/code&gt; plural and &lt;code&gt;selectordinal&lt;/code&gt; cases across 20 locales, date formatting across 19 locales, 260 date patterns (52 pattern letters × widths 1–5), and &lt;code&gt;material3-a2ui&lt;/code&gt; date and &lt;code&gt;Calendar&lt;/code&gt; cases across 29 locales.&lt;/li&gt;
&lt;li&gt;Resource resolution and strict JSON parsing: Ports AOSP's resource locale-matching logic and Android 15 region fallback tables to confirm that 174 locales resolve to the same resource directories as on the Android 15 emulator. For strict JSON parsing, we test 30 valid and malformed payloads (including leading BOMs) to verify that Desktop and iOS even throw the exact same exception messages as Android.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Running against these recordings also surfaced a few low-level platform differences. In &lt;code&gt;ja-JP&lt;/code&gt;, for example, iOS formats the yen sign as half-width &lt;code&gt;"¥"&lt;/code&gt; while Android outputs full-width &lt;code&gt;"￥"&lt;/code&gt;. We pinned those known differences explicitly in the test assertions and documented the full list in &lt;a href="https://github.com/BinaryTape/a2ui-kmp/blob/main/CHANGELOG.md" rel="noopener noreferrer"&gt;CHANGELOG.md&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reusing Upstream Tests &amp;amp; Automating Maintenance
&lt;/h2&gt;

&lt;p&gt;Because &lt;code&gt;source/&lt;/code&gt; pulls the full upstream directory tree from AOSP, we also hooked upstream's own test suites directly into our build:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upstream unit tests: All 1,446 upstream unit tests across the 6 modules run unmodified on Desktop (JDK 21).&lt;/li&gt;
&lt;li&gt;Upstream Compose UI tests: With lightweight Android test-runner and annotation stand-ins in &lt;code&gt;tests/android-test-stand-ins&lt;/code&gt;, upstream's instrumented tests run directly on Desktop via Compose Multiplatform's &lt;code&gt;runComposeUiTest&lt;/code&gt;, passing 527 UI tests in &lt;code&gt;material3-a2ui&lt;/code&gt; and all 57 UI tests in &lt;code&gt;compose-ui-testing&lt;/code&gt; (584 total). On top of that, &lt;code&gt;scripts/verify-samples.sh&lt;/code&gt; builds and launches &lt;code&gt;samples&lt;/code&gt; on both Desktop and the iOS Simulator to verify end-to-end interactions.&lt;/li&gt;
&lt;li&gt;Skipped tests: Only 8 upstream UI tests in &lt;code&gt;material3-a2ui&lt;/code&gt; are skipped on Desktop: 4 because they trigger the Android system back button, and 4 because they rely on &lt;code&gt;StateRestorationTester&lt;/code&gt;, which Compose Multiplatform hasn't implemented on Desktop yet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two automated scripts handle day-to-day maintenance and release checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;scripts/check-requirements.py&lt;/code&gt; runs after every local publish to &lt;code&gt;build/repo&lt;/code&gt;, inspecting the generated Gradle &lt;code&gt;.module&lt;/code&gt; files and the &lt;code&gt;default/manifest&lt;/code&gt; inside each iOS klib to verify that the version requirements table in &lt;code&gt;README.md&lt;/code&gt; matches the actual build artifacts.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.github/workflows/release-watch.yml&lt;/code&gt; runs &lt;code&gt;scripts/check-new-releases.py&lt;/code&gt; every night, opening a deduplicated issue in the repo whenever a new version of &lt;code&gt;androidx.a2ui&lt;/code&gt; or &lt;code&gt;material3-a2ui&lt;/code&gt; lands on Google Maven, or when the stable Compose Multiplatform 1.13 release ships.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That nightly &lt;code&gt;release-watch&lt;/code&gt; issue also sets up the next step we want to explore with tools like &lt;a href="https://pullfrog.com/" rel="noopener noreferrer"&gt;Pullfrog&lt;/a&gt;: wiring up an automated "issue → sync → PR" loop where an AI agent runs &lt;code&gt;sync-upstream.py&lt;/code&gt;, &lt;code&gt;generate-overlays.py&lt;/code&gt;, and the full &lt;code&gt;verify.sh&lt;/code&gt; suite in a sandbox and opens a pull request on its own. Those scripts catch source-sync, version, and artifact mismatches upfront. Once the agent opens the PR, humans can focus on reviewing the changelog and context behind the changes, along with the compatibility layer implementations, test results, and any updates to architecture or core logic.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;a2ui-kmp&lt;/code&gt; 1.0.0-alpha02 is now live on Maven Central, and the source is on GitHub at &lt;a href="https://github.com/BinaryTape/a2ui-kmp" rel="noopener noreferrer"&gt;github.com/BinaryTape/a2ui-kmp&lt;/a&gt; (sponsored by &lt;a href="https://littlepress.ai" rel="noopener noreferrer"&gt;LittlePress.AI&lt;/a&gt;). I think third-party renderers can swap out the Material layer for their own component set, and most of their work will live at that layer. It's not just about UI theming, either: they can share much of the official runtime underneath and build on top of it. LittlePress.AI is updating its existing Compose renderer along those lines, reusing the low-level pieces from this KMP port that fit and extending them for its own needs. Give it a try in your KMP projects, and open an issue if you have any questions or run into trouble!&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>compose</category>
      <category>a2ui</category>
    </item>
  </channel>
</rss>
