<!-- source: https://deepwiki.com/openclaw/openclaw/6.4-android-app -->

# Android App

- apps/android/app/src/debug/AndroidManifest.xml
- apps/android/app/src/debug/java/ai/openclaw/app/VoiceE2eReceiver.kt
- apps/android/app/src/main/java/ai/openclaw/app/AssistantLaunch.kt
- apps/android/app/src/main/java/ai/openclaw/app/MainActivity.kt
- apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt
- apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt
- apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayHostSecurity.kt
- apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt
- apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayTls.kt
- apps/android/app/src/main/java/ai/openclaw/app/node/ConnectionManager.kt
- apps/android/app/src/main/java/ai/openclaw/app/ui/ConnectTabScreen.kt
- apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayConfigResolver.kt
- apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayDiagnostics.kt
- apps/android/app/src/main/java/ai/openclaw/app/ui/GatewayPairingRetry.kt
- apps/android/app/src/main/java/ai/openclaw/app/ui/OnboardingFlow.kt
- apps/android/app/src/main/java/ai/openclaw/app/ui/VoiceTabScreen.kt
- apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt
- apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeGatewayConfig.kt
- apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt
- apps/android/app/src/test/java/ai/openclaw/app/GatewayBootstrapAuthTest.kt
- apps/android/app/src/test/java/ai/openclaw/app/gateway/GatewaySessionInvokeTest.kt
- apps/android/app/src/test/java/ai/openclaw/app/gateway/GatewaySessionReconnectTest.kt
- apps/android/app/src/test/java/ai/openclaw/app/node/ConnectionManagerTest.kt
- apps/android/app/src/test/java/ai/openclaw/app/ui/GatewayConfigResolverTest.kt
- apps/android/app/src/test/java/ai/openclaw/app/ui/OnboardingFlowLogicTest.kt
- apps/android/app/src/test/java/ai/openclaw/app/voice/MicCaptureManagerTest.kt
- apps/android/app/src/test/java/ai/openclaw/app/voice/TalkModeConfigParsingTest.kt
- apps/android/app/src/test/java/ai/openclaw/app/voice/TalkModeManagerTest.kt
- apps/android/scripts/voice-e2e.sh
- docs/platforms/android.md

The Android app is a native Kotlin client implementation for OpenClaw. It acts as a device node implementing the Device Node Protocol, exposing Android-specific device capabilities such as camera, location, notifications, SMS, call logs, and more to the agent runtime controlled via the Gateway. The app delivers a fluid user experience with a user interface built using Jetpack Compose and Material 3 components, optimized for mobile usage. It connects to the Gateway via WebSocket and supports gateway discovery through QR code scanning and DNS-SD (mDNS).

## Build System

The Android app uses the Gradle build system orchestrated with the Android Gradle Plugin. The main Gradle configuration is located in `apps/android/app/build.gradle.kts`.

### Build Configuration

These values ensure recent Android features and security updates are supported while maintaining compatibility with Android 12+ devices.

### Signing Configuration

Signing of release builds requires setting environment variables or Gradle project properties for the keystore and key passwords. The build script validates required signing properties when a release build is triggered and expands the home directory shorthand (`~/`) in keystore paths.

The signing configuration variables include:

```

```

This ensures security and compliance by enforcing signed release builds.

### Product Flavors

The build defines two product flavors scoped under the `store` dimension to handle permission and policy differences:

This separation helps meet platform distribution policies while maintaining a powerful user experience on sideloaded installs.

## Application Architecture

The Android app follows a Single-Activity architecture with `MainActivity` hosting the UI. The backend logic is encapsulated in `NodeRuntime`, which manages device capabilities, gateway connectivity, and application state. The UI state and logic are exposed through `MainViewModel` by leveraging Kotlin's `StateFlow` for reactive updates.

### NodeRuntime

`NodeRuntime` is the core orchestrator for the Android app's runtime environment. It initializes and integrates multiple subsystems that handle device features and gateway communication:

- Gateway Session : Maintains the persistent communication channel with the Gateway via WebSocket.
- Device Capability Handlers : These include specialized classes such as CameraHandler , LocationHandler , SmsHandler , NotificationsHandler , and more, which expose Android device functionalities to the Gateway apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt 116-187
- Connection Management : The ConnectionManager encapsulates device state tracking, capability advertisement, and TLS parameter resolution apps/android/app/src/main/java/ai/openclaw/app/node/ConnectionManager.kt 18-32
- Canvas Controller : Manages the A2UI canvas state for rendering agent-provided interactive UIs apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt 98
- Voice Interaction : Integrated through TalkModeManager and microphone/audio capture management subsystems apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt 196-200

`NodeRuntime` exposes key state flows such as discovered gateways, connection status, voice capture mode, and canvas URLs, enabling reactive consumption by the UI [apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt81-200](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt#L81-L200)

### MainViewModel

`MainViewModel` bridges the UI layer and `NodeRuntime`. It holds a reference to the runtime and provides safe reactive access to its state. It defines helper functions like `runtimeState` to map runtime `StateFlow` values to UI-observable state variables, gracefully handling runtime initialization delays [apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt59-65](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt#L59-L65)

The ViewModel exposes flows of gateways, connection states, canvas hydration status, gateway metadata, skill summaries, and various other telemetry and configuration states essential for the UI [apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt67-120](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt#L67-L120)

### Android App Architecture Components

```

```

Sources: [apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt81-200](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt#L81-L200) [apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt29-120](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt#L29-L120) [apps/android/app/src/main/java/ai/openclaw/app/node/ConnectionManager.kt18-32](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/node/ConnectionManager.kt#L18-L32)

## Voice Interaction (Talk Mode)

### TalkModeManager

The Android app implements voice interactions with the `TalkModeManager` class, handling speech recognition, voice conversation state, and text-to-speech synthesis [apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt96-106](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt#L96-L106)

It supports different execution modes:

- Native Mode : Utilizes Android's native SpeechRecognizer APIs for local speech-to-text transcription apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt 139
- Relay Mode : Streams real-time PCM16 audio frames via the Gateway using a relay protocol for low-latency transcription and agent interaction. This involves realtimeAudioQueue and realtimeAudioWriterJob for playback apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt 181-183

This manager maintains a conversation log (`_conversation`), tracks voice capture state, and interfaces with text-to-speech engines to provide seamless voice-based personal assistant features [apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt136-137](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt#L136-L137)

### MicCaptureManager

`MicCaptureManager` handles the details of audio capture from Android hardware microphones, managing audio buffers, session lifecycle, and transcription streaming to the Gateway [apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt46-63](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt#L46-L63)

It exposes `StateFlow` properties to signal audio levels (`_inputLevel`), live transcripts (`_liveTranscript`), current microphone state, and conversation entries [apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt77-102](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt#L77-L102) The manager handles buffering, message queuing, and partial transcript flushing [apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt124-154](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt#L124-L154)

### Voice Interaction Data Flow

```

```

Sources: [apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt168-183](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt#L168-L183) [apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt46-118](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt#L46-L118) [apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt181-182](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt#L181-L182)

## Gateway Connectivity

`GatewaySession` manages the WebSocket connection lifecycle to the OpenClaw Gateway server. It wraps OkHttp's WebSocket client and implements connection, authentication, reconnection, and message dispatching logic [apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt117-126](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt#L117-L126)

### Authentication

The Gateway supports multiple authentication modes defined in `GatewayConnectAuthSource` [apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt63-69](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt#L63-L69):

- DEVICE_TOKEN : Per-device token for persistent identity.
- BOOTSTRAP_TOKEN : Temporary token used on initial pairing or untrusted state.
- PASSWORD : Shared credentials for operator or node roles.

`GatewaySession` handles handshakes, authentication retries (using `pendingDeviceTokenRetry`), and TLS fingerprint probing to ensure trusted man-in-the-middle protection [apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt198-214](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt#L198-L214)

### RPC Invocation

The Gateway can invoke commands on the Android device via RPC messages encapsulated in `InvokeRequest`. These requests get routed to `InvokeDispatcher`, which delegates to subsystem handlers like camera or SMS managers [apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt135-141](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt#L135-L141) [apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt116-187](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt#L116-L187)

Handlers respond with `InvokeResult` structures containing JSON-encoded results or `ErrorShape` objects that are propagated back over the gateway connection [apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt143-156](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt#L143-L156)

Sources: [apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt63-156](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt#L63-L156) [apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt116-187](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt#L116-L187)

## Jetpack Compose UI

The Android UI uses Jetpack Compose with Material 3 components to create a modern, reactive UI experience.

- Onboarding Flow : The OnboardingFlow manages the initial setup, gateway discovery via QR scanner, and permission requests apps/android/app/src/main/java/ai/openclaw/app/ui/OnboardingFlow.kt 118-156
- State Observation : Compose functions observe StateFlow properties from MainViewModel to reactively update UI elements as runtime state changes, such as message lists, connection status, or canvas states apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt 91-120
- Canvas Integration : The CanvasController coordinates with a WebView used for rendering agent A2UI interfaces. MainViewModel exposes canvasCurrentUrl and canvasA2uiHydrated for UI rendering apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt 72-76

Sources: [apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt91-120](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt#L91-L120) [apps/android/app/src/main/java/ai/openclaw/app/ui/OnboardingFlow.kt118-156](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/ui/OnboardingFlow.kt#L118-L156)

# Summary

The OpenClaw Android app is a comprehensive native client that integrates deeply with device capabilities through a modular runtime (`NodeRuntime`) and a reactive UI built on Jetpack Compose. It features a well-structured Gradle build with environment-driven signing configurations and dual product flavors for Play Store compliance and full access builds.

Voice interaction is a central feature, managed by the sophisticated `TalkModeManager` in conjunction with native and relay-supported speech recognition and text-to-speech synthesis. The gateway connectivity subsystem manages robust WebSocket communication, authentication, and RPC invocation, enforcing secure pairing models and enabling the Android device to act as a native node in the OpenClaw ecosystem.

Sources:
[apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt81-200](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt#L81-L200)
[apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt29-120](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/MainViewModel.kt#L29-L120)
[apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt96-183](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt#L96-L183)
[apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt46-118](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/voice/MicCaptureManager.kt#L46-L118)
[apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt63-214](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt#L63-L214)
[apps/android/app/src/main/java/ai/openclaw/app/ui/OnboardingFlow.kt118-156](https://github.com/openclaw/openclaw/blob/fbdf5937/apps/android/app/src/main/java/ai/openclaw/app/ui/OnboardingFlow.kt#L118-L156)
