Part 1 of 2 — Understand the protocol, render your first surface, and connect user interactions.Imagine opening a grocery app, opening the AI Chat support and typing: “Six eggs arrived broken. Can you help?”A chatbot could reply with a long explanation, perhaps asking you to open your order history, find the product, and fill out a refund form. But what if the app displayed a small interface with the damaged item, a quantity selector, and two buttons: Refund and Replace?That is the opportunity behind Agent-to-UI (A2UI). Instead of generating only text, an AI agent describes a user interface that your Android app renders using native Jetpack Compose components.In this two-part series, we will build a small customer-support experience. In Part 1, we’ll understand the protocol and render a native surface. In Part 2, we’ll look at custom components, action security, testing, and the decisions required before using A2UI in production.What exactly is A2UI?A2UI is an open protocol for describing interactive user interfaces with structured messages. An agent sends a representation of what to display, not executable Kotlin or generated Compose source code. Your app owns the renderer and the set of components the agent can use.This is an important distinction. The agent might ask for a Card, Text, and Button, but the app determines how those elements look, behave, and fit its design system.Think of A2UI as a contract between an AI agent and a native UI renderer. It is closer to server-driven UI than to asking an LLM to write and run arbitrary code.Figure 1 — The agent describes the UI. The Android app validates and renders it using approved native components.The three ideas to remember are:1. Catalog: The set of components and properties the agent is allowed to use, it can be customized.2. Surface: An independently managed area of UI, identified by a surfaceId.3. Data model: The values displayed by the components, which can be updated independently from the layout.The result is a flexible interface without surrendering control of the Android application.When does A2UI make sense?A2UI is interesting when the right interface depends on a user request that cannot be fully anticipated at design time.Customer support: Surface targeted refund, replacement, or troubleshooting controls right inside the flow instead of forcing users through a long chat exchange.Travel: Translate a nuanced prompt like “Find a flight with one checked bag and a short layover” into an interactive comparison view complete with filters and selection controls.Banking and personal finance: Walk users through a clear spending explanation or dispute-intake workflow, while keeping sensitive actions strictly governed by the app and backend.Productivity: Turn a natural-language request straight into a usable checklist, approval form, or task summary rather than a wall of text.It is not a replacement for every Compose screen. A predictable login form, a fixed settings screen, or a navigation bar probably does not need an AI agent to decide its layout. Dynamic UI introduces complexity, latency, cost, and additional failure modes. Use it when adaptability provides enough value to justify these costs.Let’s build a customer-support surfaceOur example starts when a user reports damaged eggs. For the first version, we will replay a known-good A2UI message stream rather than connect a live model. This makes the protocol easier to understand and gives us a deterministic test case.Our expected screen is deliberately small:Once this works, the agent can later decide whether to show different content or additional components from the same catalog.Step 1: Choose the protocol versionThere is an important compatibility detail: the A2UI specification site now lists v1.0 as current, while the AndroidX Compose renderer documentation describes support for v0.9.1. For this tutorial we use the Android-documented v0.9.1 message structure. Do not silently mix v1.0 examples with a v0.9.1 renderer; check your dependency and renderer compatibility before upgrading.A2UI does not prescribe whether you use WebSockets, server-sent events, or another transport. It does require correctly framed messages, ordered delivery, and the ability to carry metadata or actions when the application needs them.Step 2: Create a surfaceThe agent first creates a surface and names the component catalog it wants to use.{ "version": "v0.9.1", "createSurface": { "surfaceId": "damaged_order", "catalogId": "https://a2ui.org/specification/v0_9_1/catalogs/basic/catalog.json" }}Here we use the A2UI Basic Catalog. AndroidX supplies a Material 3 implementation of this catalog. The catalog ID must match one supported by the client; it is not a request to download and execute UI code from that URL.Step 3: Describe the componentsNext we define our UI. Notice how each component has an ID and how parent components refer to children by ID. The protocol uses a flat component list rather than nested JSON trees.{ "version": "v0.9.1", "updateComponents": { "surfaceId": "damaged_order", "components": [ { "id": "root", "component": "Card", "child": "content" }, { "id": "content", "component": "Column", "children": ["title", "details", "message", "refund"] }, { "id": "title", "component": "Text", "text": "Damaged item", "variant": "h2" }, { "id": "details", "component": "Text", "text": "Organic eggs · Order #7731" }, { "id": "message", "component": "Text", "text": { "path": "/support/message" } }, { "id": "refund_label", "component": "Text", "text": "Request refund" }, { "id": "refund", "component": "Button", "child": "refund_label", "action": { "event": { "name": "requestRefund", "context": { "orderId": "7731" } } } } ] }}The root ID is special: it identifies the root component of the surface. The requestRefund action is an event request, not permission to issue money back to a customer. We’ll enforce that distinction in Part 2.Step 4: Update the data without rebuilding the layoutOur message text is bound to /support/message rather than stored directly in the component declaration. We can now populate it separately:{ "version": "v0.9.1", "updateDataModel": { "surfaceId": "damaged_order", "path": "/support/message", "value": "We can help with the damaged eggs." }}If the backend later sends a new updateDataModel for that path, the message changes without resending the card, column, or button structure.This separation is one of the protocol’s most useful properties. A2UI can progressively render a screen while data is still arriving. The Android renderer uses Compose snapshot state to react to incremental changes.Figure 2 — Layout updates and data updates travel separately; user events take the return path.Step 5: Render A2UI in Jetpack ComposeAndroid provides a Compose renderer with separate libraries for the A2UI model, engine, runtime, UI, and Material 3 catalog. In your Gradle setup, use a mutually compatible set of released artifacts from the Android documentation; do not guess independent versions for each module.The relevant artifacts include:// Artifact coordinates; choose compatible versions from the official docs.implementation("androidx.a2ui:a2ui-model:")implementation("androidx.a2ui:a2ui-engine:")implementation("androidx.a2ui.compose:compose-runtime:")implementation("androidx.a2ui.compose:compose-ui:")implementation("androidx.compose.material3:material3-a2ui:")In the ViewModel, the parser converts incoming JSON messages and the processor manages surface state. The following excerpt follows the structure of Android’s official documentation, with transport-specific functions left for your application to implement:class SupportViewModel : ViewModel() { private val parser = A2uiMessageParser() private val processor = A2uiMessageProcessor( catalogs = listOf(supportCatalog) // Your initialized Basic Catalog. ) val surfaces: StateFlow<List> = processor.activeSurfaces init { viewModelScope.launch(Dispatchers.Default) { processor.collectMessages() } viewModelScope.launch(start = CoroutineStart.UNDISPATCHED) { processor.outboundEvents.collect { event -> // Forward through your authenticated application transport. sendToBackend(event) } } } fun onAgentMessage(json: String) { processor.processInput(parser, json) }}supportCatalog and sendToBackend are application integration points, not APIs supplied by A2UI. For the Basic Catalog initializer and its media/URL callbacks, follow the official catalog setup guideThen render the active surfaces like any other piece of Compose UI:@Composablefun SupportScreen(viewModel: SupportViewModel) { val surfaces by viewModel.surfaces.collectAsStateWithLifecycle() Column(Modifier.fillMaxSize()) { surfaces.forEach { surface -> key(surface.id) { A2uiSurface(surfaceModel = surface) } } }}No WebView is needed here. The app displays Material 3 components through the renderer, and those components can participate in your existing Compose layout.For a first test, feed the three JSON messages above to onAgentMessage in order. Once the UI is visible, send another updateDataModel message changing /support/message. Only the bound content needs to update.What happens when the user taps the button?The component declares a named event, requestRefund. When tapped, the renderer emits an outbound action event. Your Android application must take that event, forward it to the correct endpoint, and handle the outcome.A production backend must not trust the order ID or refund eligibility simply because the agent placed them in an action’s context. It must derive the user’s identity from authentication, verify access to the order, check refund eligibility, and request explicit confirmation when appropriate.In other words, A2UI renders an interface. It is not a transaction authorization protocol.ConclusionIn a traditional Android app, developers usually decide the structure of each screen ahead of time. With A2UI, we can allow an agent to select and compose a UI dynamically, while the application continues to own its component implementations.We have now covered the fundamentals: catalogs, surfaces, component trees, data bindings, action events, and native rendering with Compose. The most important point is that the agent controls the composition, not the code your app executes.But rendering a button is the easy part. Should the agent be allowed to trigger a refund? What happens when it invents a component? How do we test a UI whose layout changes with the user’s request?A2UI for Android: Let AI Agents Build Native Jetpack Compose Interfaces was originally published in ProAndroidDev on Medium, where people are continuing the conversation by highlighting and responding to this story.
A2UI for Android: Let AI Agents Build Native Jetpack Compose Interfaces
A2UI for Android: Let AI Agents Build Native Jetpack Compose Interfaces
Editor
Dec 3, 2026 · 9 min read

From other categories

Databases
How Atlan Moved Its Data Platform from Spark and StarRocks to DuckDB on S3
just now·7 min

Security
Lunex Stealer Targets European Hospitality Firms With Fake Google Translate Extension
just now·1 min

Operating Systems
FreeCAD 26.3 Open-Source 3D Parametric Modeler Released, Here’s What’s New
1h ago·1 min

Hardware
Save $90 on this 3-item gaming combo with Ryzen 7 5800X3D, 32GB RAM, and Asus TUF Gaming motherboard from Newegg
1h ago·4 min

AI & Machine Learning
Intuit and OpenAI build NightFalcon to secure complex workflows
3h ago·1 min

Programming Languages
Handling Irreducibility in a Just-in-Time Compiler
17h ago·1 min