Build AndroidOS Apps is a Codex plugin for modern Android application
development with Kotlin, Jetpack Compose, Material 3, Gradle, adb, visible
Codex side-panel emulator previews, performance profiling, and memory
investigation.
The plugin organizes each development responsibility around Android-native tools and conventions.
This repository is a Codex plugin, not an Android Studio project template and not a replacement for the Android SDK.
When a request matches one or more included skills, Codex loads the relevant workflow instructions and applies them to the current repository. The plugin is designed to help Codex:
- inspect an existing Gradle build before editing it
- preserve the repository's architecture and dependency conventions
- create or modernize Kotlin and Jetpack Compose projects conservatively
- build Material 3 adaptive UI for phones, tablets, foldables, and multi-window layouts
- expose shortcuts, deep links, App Links, and App Actions through a coherent routing model
- build, install, launch, inspect, and debug apps on an explicit adb target
- mirror a booted Android emulator or device into the visible Codex side-panel browser for visual preview and light interaction
- audit Compose code before collecting runtime performance traces
- choose Macrobenchmark, Baseline Profiles, Perfetto, Simpleperf, or
gfxinfoaccording to the question - distinguish Java or Kotlin heap retention from native memory growth
- validate changes with the narrowest useful Gradle tasks and device flows
The plugin intentionally does not require a third-party Android MCP server. Device work uses the Gradle wrapper, Android SDK command-line tools, adb, UI Automator, and Android profiling tools.
The plugin uses progressive skill loading.
- Codex reads the request and matches it against the descriptions of the included skills.
- It loads only the relevant
SKILL.mdfiles. - A selected skill may load a focused reference document or bundled helper script when the task needs more detail.
- Codex inspects the target repository and follows its existing conventions.
- It implements the smallest justified change.
- It runs focused verification, then broadens checks when shared behavior or a platform boundary changed.
- For runtime bugs, it reproduces the same flow after the patch and reports the target, variant, evidence, and remaining caveats.
A single task can activate more than one skill. For example:
- a new large-screen settings flow can use
compose-ui-patterns,material3-adaptive-ui, andandroid-project-setup - a janky scrolling issue can use
compose-performance-audit,android-runtime-performance,android-debugger-agent, andandroid-emulator-browserfor browser-visible proof - a retained activity can use
android-memory-leaksandandroid-debugger-agent - an Assistant entry point can use
android-app-actionsand the project's existing navigation layer
v0.1.3 packages the repository as a Codex Git marketplace. The repository now
exposes the plugin from plugins/build-androidos-apps through
.agents/plugins/marketplace.json, while preserving the side-panel browser
guidance from v0.1.2.
Set up or modernize Android projects with current Kotlin, Compose, Material 3, and Gradle conventions.
Use it for:
- new Android apps and modules
- Kotlin DSL and version catalogs
- Android Gradle Plugin upgrades
- AGP 9 built-in Kotlin migration
- Compose Compiler plugin and Compose BOM setup
- Material 3 dependencies
- Gradle wrapper and JDK compatibility
compileSdk,targetSdk, andminSdkdecisions- KSP or kapt migration
- build-tool compatibility repairs
Strong defaults:
- inspect
settings.gradle.kts, module build files, version catalogs, wrapper configuration, and existing modules before editing - use the checked-in
./gradlewwrapper - keep dependency versions centralized when the repository already uses a version catalog
- use stable dependencies for production unless a requested API requires a preview artifact
- prefer KSP over kapt when the dependency supports it
- keep
minSdktied to product requirements - re-check official Android documentation before making version-sensitive claims
For AGP 9 and later, the skill accounts for built-in Kotlin before applying or
retaining org.jetbrains.kotlin.android. A build migration is kept separate
from unrelated feature work.
Build, install, launch, inspect, and debug Android apps on an explicit adb target.
Use it for:
- discovering emulators and connected devices
- selecting a build variant
- building and installing an app
- resolving and launching the target activity
- capturing screenshots and UI trees
- computing UI interaction coordinates from accessibility nodes
- driving a repeatable emulator flow
- collecting filtered logcat and crash logs
- validating user-visible fixes
The workflow starts by selecting one target explicitly:
adb devices -l
emulator -list-avdsIt then discovers repository tasks and installs the requested variant:
./gradlew tasks --all
./gradlew :app:installDebug --console=plainFor runtime interaction, it captures visual and structural evidence:
adb -s <serial> exec-out screencap -p > /tmp/android-screen.png
adb -s <serial> exec-out uiautomator dump /dev/tty > /tmp/android-ui.xmlStrong defaults:
- pass
-s <serial>on adb commands when more than one target is attached - fix the first actionable build error before attempting UI interaction
- re-dump the UI tree after navigation or state changes
- prefer Compose semantic matchers and test tags for stable automated UI tests
- use a physical device when hardware, OEM behavior, or representative performance matters
Mirror a booted Android emulator or connected adb device into the visible Codex side-panel browser.
Use it for:
- keeping an Android runtime preview visible inside Codex
- interacting with an emulator through browser clicks, key buttons, and text input
- capturing browser-visible proof after UI changes
- reviewing Compose UI in a running preview, sample, debug, or host activity
- pairing visual preview with
android-debugger-agentscreenshots, UI trees, and logcat
The workflow follows the same operational shape as the latest iOS simulator browser skill:
adb devices -l
SERIAL="<adb-serial>"
node skills/android-emulator-browser/scripts/android-emulator-browser.mjs \
--serial "$SERIAL"Open the exact local URL printed by the bridge in the visible Codex side-panel browser and confirm that a real Android frame is rendering before reporting success.
Strong defaults:
- select one adb serial explicitly when multiple targets are attached
- build, install, and launch the app before mirroring unless the current device state is the target
- keep the bridge terminal alive while the preview is open
- treat the browser bridge as visual proof and light interaction; use UI Automator and logcat for structural debugging
- use a physical device for hardware-specific behavior
Current serve-sim releases are Apple Simulator-oriented. For Android browser
previews, this plugin provides a bundled adb-based bridge instead of calling
serve-sim directly against an adb serial.
Expose useful app destinations and actions outside the main UI.
Use it for:
- deep links
- verified Android App Links
- static launcher shortcuts
- dynamic or pinned shortcuts
- Google Assistant App Actions
shortcuts.xmlcapabilities- external intent routing
- cold-start and warm-start destination validation
The workflow starts with the smallest user-facing verbs and destinations:
- open
- search
- compose
- continue
- create
- record
- inspect
Strong defaults:
- expose a small, high-value surface instead of mirroring the full navigation tree
- route shortcuts, links, notifications, widgets, and in-app actions through one destination or domain-command model
- validate and sanitize inbound URI parameters
- use App Actions only when a supported Assistant built-in intent or justified custom intent maps cleanly to the feature
- verify runtime fulfillment instead of stopping after XML compilation
Build modern Material 3 Compose UI that responds to the current app window.
Use it for:
- phone, tablet, foldable, and multi-window layouts
- compact, medium, and expanded window behavior
- Material 3
Scaffold NavigationSuiteScaffoldListDetailPaneScaffoldSupportingPaneScaffoldcurrentWindowAdaptiveInfo()- edge-to-edge drawing and
WindowInsets - system bars, display cutouts, and IME behavior
- keyboard, mouse, trackpad, stylus, and accessibility review
Strong defaults:
- use the current app window as the source of layout truth
- keep adaptation separate from business state
- add useful structure in expanded layouts instead of stretching phone UI
- apply insets exactly once
- preserve state and back behavior across window-size and posture changes
- verify gesture navigation, three-button navigation, cutouts, and IME appearance where relevant
The skill expects edge-to-edge behavior to be reviewed deliberately when targeting modern Android SDK levels.
Build Compose UI as a stable rendering layer with explicit state ownership.
Use it for:
- new screens and reusable composables
- state hoisting
- screen-level ViewModels
- lifecycle-aware
StateFlowcollection - unidirectional data flow
- navigation and controlled side effects
- forms, lazy lists, dialogs, sheets, and async content
- previews, semantics, accessibility, and UI tests
The default state model is:
| State kind | Default owner |
|---|---|
| Simple element state used by one composable | Local remember |
| Saveable UI state | rememberSaveable |
| Complex reusable UI behavior | Plain state holder remembered by the UI |
| Screen state driven by business or data-layer logic | Screen-level ViewModel exposing immutable UI state |
Strong defaults:
- immutable state flows down and explicit events flow up
- business logic stays outside reusable composables
- repository and network calls do not run directly from composable bodies
- leaf composables receive plain values and callbacks
- flow collection is lifecycle aware
- lazy collections use stable keys
CompositionLocalis used narrowly for tree-scoped infrastructure rather than as a default service locator
Refactor large Compose screens without changing user-visible behavior.
Use it for:
- oversized composable files
- route wiring mixed with reusable rendering
- inline business logic
- broad or unclear state ownership
- missing lazy-list keys
- unstable parameters
- overused
CompositionLocal - composition-time parsing, sorting, filtering, or formatting
- repeated effect restarts
The workflow separates route-level wiring from reusable screen content:
@Composable
fun SearchRoute(
onOpenResult: (String) -> Unit,
viewModel: SearchViewModel = viewModel(),
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
SearchScreen(
uiState = uiState,
onQueryChange = viewModel::updateQuery,
onOpenResult = onOpenResult,
)
}Strong defaults:
- extract meaningful composables instead of hiding an entire screen behind many private rendering helpers
- pass only the data and callbacks a child needs
- keep simple element state local
- avoid introducing a ViewModel for every component
- move repository calls and expensive transformations out of composition
- do not claim a performance improvement without measurement when performance is the stated goal
Audit Compose performance from code before collecting traces.
Use it for:
- scroll jank
- frame drops
- excessive recomposition
- broad state invalidation
- unstable parameters
- lazy-list identity issues
- expensive composition-time transformations
- effect restart loops
- intrinsic measurement and layout cost
- draw-phase work
- oversized images and synchronous decode paths
The investigation order is:
- Narrow broad state reads.
- Stabilize lazy-list identity.
- Remove heavy work from composition.
- Check effects and lifecycle-aware collection.
- Inspect layout and draw cost.
- Capture Macrobenchmark or Perfetto evidence when runtime proof is needed.
Strong defaults:
- narrow observation scope before adding memoization
- use
rememberandderivedStateOfonly when they reduce real work and have correct keys - downsample images before rendering
- separate code-backed findings from trace-backed evidence
- do not claim improvement from emulator feel alone
Capture and interpret focused Android runtime performance evidence.
Use it for:
- startup latency
- frame timing and jank
- scrolling and animation performance
- CPU-heavy Kotlin, Java, native, or framework stacks
- before-and-after optimization comparisons
- Baseline Profile generation
- scheduler stalls, binder work, locks, and timeline analysis
- native allocation growth
Choose the evidence source according to the question:
| Tool | Best fit |
|---|---|
| Macrobenchmark | Repeatable app-level startup, frame, scrolling, animation, and interaction metrics |
| Baseline Profiles | Precompile important startup and interaction paths that users feel immediately |
| Perfetto | Timeline root cause, frame lanes, scheduler gaps, main-thread stalls, binder work, locks, and trace sections |
| Simpleperf | Sampled Kotlin, Java, native, and framework CPU stacks |
gfxinfo framestats |
Fast directional frame snapshot before deeper tracing |
heapprofd |
Native allocation traces when Java or Kotlin heap analysis is not enough |
Strong defaults:
- profile one user-visible flow with exact start and stop points
- record device, Android version, variant, build type, compilation mode, and run count
- benchmark a
profileabletarget variant - prefer a physical device for representative numbers
- treat emulator measurements as workflow rehearsal or coarse direction
- preserve JSON and trace artifacts from the exact run
- compare only equivalent captures
Investigate retained objects and native allocation growth with repeatable evidence.
Use it for:
- retained activities and fragments
- Compose state holders
- contexts, views, drawables, and bitmaps
- listeners and callbacks
- coroutines and flows
- adapters and caches
- singleton retention
- native allocation growth
- unexplained memory pressure
The evidence ladder is:
- Use
dumpsys meminfofor directional process memory and object counts. - Capture an Android-format HPROF heap dump.
- Inspect class counts, retained sizes, fields, and references with Android Studio Profiler.
- Use Shark CLI or existing LeakCanary reports when a text reference chain is useful.
- Use Perfetto
heapprofdfor native allocation growth.
Strong defaults:
- return to the same idle point before each capture
- treat one
meminfoincrease as a lead, not proof - prove a leak with a retained object and GC-root path or a repeatable accumulation pattern
- distinguish process-lifetime caches from feature-lifetime leaks
- remove the retaining edge instead of adding broad cleanup calls
- confirm that the same retained type or path disappears after the patch
Example prompt:
Create an Android app with Kotlin, Jetpack Compose, Material 3, a version
catalog, and the current AGP built-in Kotlin conventions.
Expected workflow:
- Load
android-project-setup. - Inspect the existing build or scaffold the requested modules.
- Re-check official AGP, Compose BOM, Kotlin, SDK, and JDK guidance.
- Configure the smallest necessary Gradle surface.
- Run
./gradlew help, a debug assembly, and relevant tests or lint tasks.
Example prompt:
Refactor this list-detail screen for phones, tablets, foldables, and
multi-window mode. Preserve state while switching between one and two panes.
Expected workflow:
- Load
material3-adaptive-ui,compose-ui-patterns, and possiblycompose-view-refactor. - Define compact, medium, and expanded behavior.
- Choose native adaptive scaffolds where they fit.
- Handle insets exactly once.
- Verify resize, rotation, posture, back behavior, IME, focus, and accessibility.
Example prompt:
Launch the debug app on the emulator, reproduce the login crash, and inspect
the filtered logcat output.
Expected workflow:
- Load
android-debugger-agent. - Select one adb serial and discover the correct install task.
- Build and install before UI interaction.
- Resolve the launcher activity and capture the initial screenshot and UI tree.
- Reproduce the exact flow.
- Collect app-pid and crash-buffer logcat evidence.
- Patch and replay the same flow.
Example prompt:
Launch the debug app on an emulator and show it in the Codex side-panel browser
while I review the Compose screen.
Expected workflow:
- Load
android-debugger-agentandandroid-emulator-browser. - Select or boot one adb target and install the requested variant.
- Launch the target package or activity.
- Start
android-emulator-browser.mjs --serial <adb-serial>in a long-running terminal. - Open the printed localhost URL in the visible Codex side-panel browser.
- Verify a real Android frame is rendering, then use browser-visible proof for the closeout.
Example prompt:
Add a verified App Link for product details and a launcher shortcut for recent
orders. Route both through the existing navigation model.
Expected workflow:
- Load
android-app-actions. - Choose the smallest external surfaces that satisfy the use case.
- Centralize URI parsing and parameter validation.
- Reuse the same typed destination model as in-app navigation.
- Verify cold-start, warm-start, invalid-input, and back-stack behavior.
Example prompt:
The Compose feed drops frames while scrolling. Find the root cause and prove
the improvement.
Expected workflow:
- Load
compose-performance-audit. - Inspect state reads, lazy keys, composition-time work, layout, draw, and image paths.
- Apply a narrow code fix when the cause is clear.
- Load
android-runtime-performancewhen runtime evidence is required. - Capture comparable Macrobenchmark and Perfetto evidence on the same target.
Example prompt:
Memory grows after repeatedly entering and leaving the camera screen. Find the
retaining path and verify the fix.
Expected workflow:
- Load
android-memory-leaksandandroid-debugger-agent. - Build and launch the exact variant.
- Reproduce the same flow and return to a stable idle point.
- Capture
meminfoand an HPROF heap dump. - Inspect retained app-owned objects and GC-root chains.
- Patch the smallest retaining edge.
- Repeat the same capture and compare the same retained types.
The plugin includes small helpers for repeatable diagnostics. They use standard Python, shell, Android SDK, and profiling tools. They do not replace direct UI, heap, or trace inspection.
python3 skills/android-debugger-agent/scripts/ui_tree_summarize.py \
/tmp/android-ui.xml \
/tmp/android-ui-summary.txtReads a UI Automator XML dump and writes a compact text summary for inspection.
python3 skills/android-debugger-agent/scripts/ui_pick.py \
/tmp/android-ui.xml \
"Settings"Searches the UI Automator XML tree for text and prints coordinates suitable for an adb tap command. Re-dump the tree after navigation or layout changes.
skills/android-memory-leaks/scripts/capture_android_memory.sh \
--serial <adb-serial> \
--package <application-id> \
--out-dir /tmp/android-memory \
--label after-flowCaptures dumpsys meminfo output and pulls an Android-format HPROF heap dump
from a running app.
node skills/android-emulator-browser/scripts/android-emulator-browser.mjs \
--serial <adb-serial>Serves a local browser UI that refreshes adb screenshots and forwards basic tap, swipe, text, and key input through adb. Open the printed URL in the visible Codex side-panel browser.
For a clean emulator validation run, use an explicit adb target and keep the bridge in its own long-running terminal:
emulator -avd <avd-name> -no-window -no-audio -no-boot-anim -no-snapshot
adb -s <adb-serial> wait-for-device
adb -s <adb-serial> shell getprop sys.boot_completed
node skills/android-emulator-browser/scripts/android-emulator-browser.mjs \
--serial <adb-serial>The browser page should show a real Android frame, not just a loaded localhost
shell. Validate at least one input path, such as tapping a launcher icon or
pressing the page's Home button and confirming the focused Android activity
with dumpsys window.
skills/android-runtime-performance/scripts/simpleperf_hotspots.sh \
/path/to/perf.data \
/tmp/android-perf \
--serial <adb-serial> \
--first-party-regex 'com\.example\.app'Generates Simpleperf self-time, inclusive, and optional CSV reports for a focused capture.
skills/android-runtime-performance/scripts/heapprofd_reports.sh \
/path/to/native-alloc.pftrace \
/tmp/android-native-allocGenerates text reports from a Perfetto trace captured with the heapprofd data
source enabled.
Install Android Studio or the Android SDK command-line tools required by the project.
Baseline checks:
java -version
adb version
adb devices -l
emulator -list-avds
./gradlew helpTypical requirements:
| Concern | Typical tools |
|---|---|
| Build | Project Gradle wrapper, compatible JDK, Android SDK platforms, and Build Tools |
| Device debugging | SDK platform-tools, adb, a booted emulator or connected device |
| Browser preview | Node.js, adb, a booted emulator or connected device that supports screencap and input |
| UI inspection | UI Automator dump support, screenshots, Compose semantics, and optional instrumented UI tests |
| Performance | Macrobenchmark module, profileable app variant, Perfetto, Simpleperf, and a physical device for representative metrics |
| Memory | dumpsys meminfo, heap-dump support, Android Studio Profiler, optional Shark or LeakCanary, and Perfetto heapprofd for native allocations |
| External actions | App manifest, shortcuts.xml where required, owned web-domain configuration for verified App Links, and current Assistant support checks |
The plugin does not assume that all tools are globally available. It first
checks the repository wrapper, SDK paths such as $ANDROID_SDK_ROOT, and the
active adb target.
Install the repository as a Codex Git marketplace:
codex plugin marketplace add SangkuOh/build-androidos-apps --ref v0.1.3
codex plugin add build-androidos-apps@build-androidos-apps
codex plugin listThe repository includes .agents/plugins/marketplace.json, so Codex can track
it as a marketplace source directly. The marketplace exposes the plugin at the
plugins/build-androidos-apps path and gates it to Codex through the same
products: ["CODEX"] policy shape used by Codex-native development plugins.
For local development, clone the plugin into a local Codex plugin source directory:
mkdir -p ~/plugins
git clone https://github.com/SangkuOh/build-androidos-apps.git \
~/plugins/build-androidos-appsRegister the local repository as its own Codex marketplace, then install the plugin from that marketplace:
codex plugin marketplace add ~/plugins/build-androidos-apps
codex plugin add build-androidos-apps@build-androidos-apps
codex plugin listTo update an existing local install:
git -C ~/plugins/build-androidos-apps pull --ff-only
codex plugin marketplace upgrade build-androidos-apps
codex plugin remove build-androidos-apps@build-androidos-apps
codex plugin add build-androidos-apps@build-androidos-appsStart a new Codex thread after installation so the new plugin skills are available to the conversation.
.
|-- .agents/
| `-- plugins/
| `-- marketplace.json
|-- plugins/
| `-- build-androidos-apps/
| |-- .codex-plugin/
| | `-- plugin.json
| |-- agents/
| | `-- openai.yaml
| |-- assets/
| | |-- app-icon.png
| | `-- build-androidos-apps-small.svg
| `-- skills/
| |-- android-project-setup/
| |-- android-debugger-agent/
| |-- android-emulator-browser/
| |-- android-app-actions/
| |-- material3-adaptive-ui/
| |-- compose-ui-patterns/
| |-- compose-view-refactor/
| |-- compose-performance-audit/
| |-- android-runtime-performance/
| `-- android-memory-leaks/
|-- LICENSE
`-- README.md
Each skill contains a SKILL.md. Larger workflows load focused material from
their own references/ directory. Diagnostic helpers live under the relevant
skill's scripts/ directory.
The plugin is intentionally conservative about claiming success.
- Build failures are fixed before UI interaction.
- Device workflows use an explicit adb serial.
- Browser previews prove that a real Android frame is rendering, not only that a localhost page loaded.
- Browser-preview input forwarding is verified by pairing the browser action with Android focus or UI-tree evidence.
- UI trees are refreshed after navigation or layout changes.
- User-visible flows are replayed after a patch.
- Compose performance review starts with code and state flow.
- Representative performance numbers come from comparable runs on a physical device.
- Emulator metrics are treated as directional evidence.
- Macrobenchmark captures record variant, compilation mode, target, and run count.
- CPU samples are not treated as wall-clock latency evidence.
- Memory conclusions distinguish heap retention from native allocation growth.
- A smaller process snapshot alone is not treated as proof of a leak fix.
- External URI parameters are validated before routing.
- App Actions are verified at runtime instead of only compiling XML.
Use current official Android documentation for version-sensitive decisions:
- Android Gradle Plugin release notes
- Migrate to built-in Kotlin
- Compose BOM
- Compose state hoisting
- Build adaptive apps
- Window insets
- Android Debug Bridge
- UI Automator
- App shortcuts
- Android App Links
- App Actions overview
- Macrobenchmark overview
- Baseline Profiles
- Perfetto system tracing
- Memory Profiler
MIT. See LICENSE.