Skip to content

lmee/A2UI-Android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

366 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A2UI: Agent-to-User Interface

License: Apache 2.0 Android Kotlin API

πŸš€ This is a fork of google/A2UI with a complete Android Jetpack Compose Renderer implementation.

Gallery of A2UI components

🌟 What is A2UI-Android?

A2UI-Android is a powerful, production-ready Android rendering engine for the A2UI Protocol that enables your Android apps to dynamically render beautiful, interactive user interfaces generated by AI agents.

Imagine your AI assistant being able to create rich, native Android UIs on-the-fly instead of just text responses - forms with validation, data dashboards, interactive cards, and more. That's what A2UI-Android makes possible!

🎯 Why Choose A2UI-Android?

πŸ€– AI-Powered UIs πŸ”’ Secure by Design ⚑ High Performance
Let AI agents generate native Android interfaces dynamically Declarative JSON format - no arbitrary code execution Optimized with rememberSaveable, lazy rendering, and smart recomposition
🎨 Fully Customizable β™Ώ Accessible πŸ“± Wide Compatibility
Dynamic themes, colors, dark mode, custom components WCAG A compliant with full TalkBack support Android 5.0+ (API 21) - covers 99%+ of devices

✨ Feature Highlights

  • 20+ Ready-to-Use Components: Text, Button, TextField, Card, List, Modal, Tabs, Slider, DatePicker, and more
  • Smart Data Binding: Two-way binding with path expressions (/user/profile/name)
  • Built-in Validation: Email, URL, phone, regex, length, required fields - all out of the box
  • Real-time Updates: WebSocket and SSE transport for live UI updates from agents
  • State Persistence: Survives configuration changes, process death, and screen rotations
  • Beautiful Animations: Smooth transitions and modal animations built-in
  • Comprehensive Testing: 49+ unit tests with 100% core functionality coverage

πŸ“± Supported Components

Text β€’ Button β€’ TextField β€’ CheckBox β€’ Switch β€’ Slider
ChoicePicker β€’ Dropdown β€’ Card β€’ Row β€’ Column β€’ List
Tabs β€’ Modal β€’ Image β€’ Icon β€’ Divider β€’ Spacer
ProgressBar β€’ DateTimeInput β€’ Video β€’ AudioPlayer β€’ Surface

πŸƒ Quick Start

@Composable
fun A2UIScreen() {
    val renderer = rememberA2UIRenderer()
    
    // Process A2UI message
    renderer.processMessage("""
        {
            "version": "v0.10",
            "createSurface": {
                "surfaceId": "hello",
                "catalogId": "https://a2ui.org/catalog.json"
            }
        }
    """)
    
    // Render UI
    A2UISurface(surfaceId = "hello")
}

πŸ“¦ Installation

Add the compose module to your project:

// settings.gradle.kts
include(":android_compose")

// build.gradle.kts
dependencies {
    implementation(project(":android_compose"))
}

πŸ“– Full Documentation

See android_compose/README.md for complete documentation including:

  • Architecture overview
  • Component reference
  • Theme customization
  • Network integration
  • Error handling
  • Testing guide

πŸ“‹ Project Overview

A2UI is an open standard and set of libraries that allows agents to "speak UI." Agents send a declarative JSON format describing the intent of the UI. The client application then renders this using its own native component library.

Why A2UI?

  • Security First: Declarative data format, not executable code
  • LLM-Friendly: Flat component list, easy for LLMs to generate incrementally
  • Framework-Agnostic: Same JSON payload renders on multiple platforms
  • Flexibility: Open registry pattern for custom components

Available Renderers

Platform Status Location
Android (Compose) βœ… Complete android_compose/
Web (Lit) βœ… Available renderers/lit/
Flutter βœ… Available GenUI SDK
React πŸ”œ Planned -
iOS (SwiftUI) πŸ”œ Planned -

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   A2UI Agent    │────▢│    Transport    │────▢│    Renderer     β”‚
β”‚   (Backend)     β”‚     β”‚  WebSocket/SSE  β”‚     β”‚   (Compose)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                                               β”‚
        β”‚  JSON Message                                 β”‚
        β–Ό                                               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  {                                                              β”‚
β”‚    "version": "v0.10",                                          β”‚
β”‚    "createSurface": { "surfaceId": "main", ... },               β”‚
β”‚    "updateComponents": { "components": [...] }                  β”‚
β”‚  }                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Getting Started

Prerequisites

  • Android Studio Hedgehog (2023.1.1) or later
  • Android SDK 21+ (Android 5.0 Lollipop)
  • Kotlin 1.9.22
  • JDK 17

Running the Android Demo

  1. Clone the repository:

    git clone https://github.com/lmee/A2UI-Android.git
    cd A2UI-Android
  2. Open in Android Studio:

    • Open Android Studio
    • Select "Open an existing project"
    • Navigate to the cloned directory
  3. Run the app:

    • Select a device or emulator
    • Click "Run" or press Shift+F10

Running the Web Demo (Original)

For the original web-based demo:

# Set API key
export GEMINI_API_KEY="your_gemini_api_key"

# Run Agent
cd samples/agent/adk/restaurant_finder
uv run .

# Run Client (new terminal)
cd renderers/web_core && npm install && npm run build
cd ../lit && npm install && npm run build
cd ../../samples/client/lit/shell && npm install && npm run dev

πŸ“ Project Structure

A2UI/
β”œβ”€β”€ android_compose/            # πŸ†• Android Compose Renderer
β”‚   β”œβ”€β”€ src/main/java/org/a2ui/compose/
β”‚   β”‚   β”œβ”€β”€ data/              # Data model & processing
β”‚   β”‚   β”œβ”€β”€ rendering/         # Core renderer & components
β”‚   β”‚   β”œβ”€β”€ transport/         # Network layer (WebSocket/SSE)
β”‚   β”‚   β”œβ”€β”€ theme/             # Theme customization
β”‚   β”‚   β”œβ”€β”€ error/             # Error handling
β”‚   β”‚   └── example/           # Demo application
β”‚   β”œβ”€β”€ src/test/              # Unit tests (49 tests)
β”‚   β”œβ”€β”€ build.gradle.kts       # Build configuration
β”‚   └── README.md              # Full documentation
β”œβ”€β”€ renderers/
β”‚   β”œβ”€β”€ web_core/              # Web core library
β”‚   └── lit/                   # Lit renderer
β”œβ”€β”€ samples/
β”‚   β”œβ”€β”€ agent/                 # Agent examples
β”‚   └── client/                # Client examples
β”œβ”€β”€ docs/                      # Documentation
└── specification/             # A2UI specification

πŸ”§ Android Compose Features

Component Example

// Define UI via JSON
val message = """
{
    "version": "v0.10",
    "updateComponents": {
        "surfaceId": "form",
        "components": [
            {
                "id": "email_field",
                "component": "TextField",
                "label": "Email",
                "value": { "path": "/form/email" },
                "required": true,
                "checks": [
                    { "call": "email", "message": "Invalid email format" }
                ]
            },
            {
                "id": "submit_btn",
                "component": "Button",
                "text": "Submit",
                "action": { "event": { "name": "submit_form" } }
            }
        ]
    }
}
"""

Theme Customization

val themeConfig = A2UIThemeConfig(
    primaryColor = "#6200EE",
    secondaryColor = "#03DAC6",
    darkMode = false
)

A2UITheme(config = themeConfig) {
    A2UISurface(surfaceId = "main")
}

⚠️ Status: Early Stage Public Preview

Note: A2UI is currently in v0.10 (Public Preview). The specification and implementations are functional but are still evolving.


πŸ—ΊοΈ Roadmap

  • Android Compose Renderer (Complete)
  • React Renderer
  • iOS SwiftUI Renderer
  • REST Transport Support
  • Additional Agent Frameworks (Genkit, LangGraph)

🀝 Contributing

A2UI is an Apache 2.0 licensed project. We welcome contributions!

See CONTRIBUTING.md for details.

Development Setup

# Clone and setup
git clone https://github.com/lmee/A2UI-Android.git
cd A2UI-Android

# Run tests
./gradlew :android_compose:test

# Build
./gradlew :android_compose:build

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


πŸ”— Links


Maintained by the A2UI Community

About

πŸš€ Production-ready Android Jetpack Compose renderer for A2UI Protocol. Let AI agents dynamically generate beautiful, interactive native Android UIs with 20+ components, smart data binding, validation, and full accessibility support. Android 5.0+ compatible.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors