Skip to content
Β 
Β 

Repository files navigation

πŸ€– Codex App Android

πŸ“± OpenAI Codex CLI β€” Running Natively on Your Android Phone πŸ“±

Android Kotlin Node.js Vue Codex Status Stars


A self-contained Android APK that bundles an entire Linux environment, installs the OpenAI Codex CLI, and gives you a full coding agent UI right on your phone. No root. No Termux. One APK.


╔═══════════════════════════════════════════════╗
β•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•—   β•‘
β•‘  β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•   β•‘
β•‘  β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β•šβ–ˆβ–ˆβ–ˆβ•”β•    β•‘
β•‘  β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•   β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—    β•‘
β•‘  β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•—   β•‘
β•‘   β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•   β•‘
β•‘     A N D R O I D  Β·  M O B I L E  Β·  A P K   β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

🀯 What Is This?

OpenAI shipped Codex CLI β€” a terminal-based AI coding agent that reads your codebase, writes code, runs commands, and iterates. It's incredible. But it only runs on macOS and Linux.

We put it on Android. Yes, the full native Rust binary. Yes, with a real web UI. Yes, on your phone.

This project packages a complete Linux userland (borrowed from Termux's bootstrap), installs Node.js 24, the Codex CLI v0.104.0 with its native aarch64 binary, wires up a Vue.js web frontend, and serves it all through an Android WebView β€” in a single APK that installs like any other app.

One APK. Zero dependencies. Full AI coding agent in your pocket. 🧠


🌍 What Can You Do With This?

Use Case Description
πŸ’¬ Chat with Codex Full conversational coding agent with streaming responses
πŸ“ Write code on the go Generate, refactor, and debug code from your phone
πŸ”§ Execute commands Codex runs shell commands in the embedded Linux environment
🧠 Reasoning visibility Watch the model think in real-time with reasoning summaries
πŸ“‚ Multi-thread sessions Multiple parallel conversations, each with its own context
πŸ”“ Full auto-approval No permission popups β€” danger-full-access mode by default
πŸŒ™ Background execution Foreground service keeps Codex alive when you switch apps
πŸ”‘ OAuth login Authenticate with your OpenAI account via browser β€” no API key pasting
🌐 DNS proxy bridge Native musl binary routes through Node.js CONNECT proxy for DNS/TLS
πŸ“± Offline-ready bootstrap Linux environment extracted from APK β€” works without internet after setup

⚑ Quick Start

# πŸ”¨ Clone the repo
git clone https://github.com/friuns2/codex-app-android.git
cd codex-app-android

# πŸ“¦ Install deps & build frontend
npm install && npm run build

# 🐧 Download Termux bootstrap (one-time, ~50MB)
cd android && bash scripts/download-bootstrap.sh

# πŸ“± Bundle, build APK, install, launch
bash scripts/build-server-bundle.sh && ./gradlew assembleDebug \
  && adb install -r app/build/outputs/apk/debug/app-debug.apk \
  && adb shell am start -n com.codex.mobile/.MainActivity
# πŸš€ You're flying!

πŸ—οΈ Architecture

Four layers. One APK. Zero compromises.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     πŸ“± Android APK                       β”‚
β”‚                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ πŸ–₯️ WebView β”‚  β”‚  πŸ“¦ APK Assets                     β”‚ β”‚
β”‚  β”‚  (Vue.js)  β”‚  β”‚  bootstrap-aarch64.zip              β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β”‚  server-bundle/ (Vue + Express)     β”‚ β”‚
β”‚        β”‚         β”‚  proxy.js (CONNECT proxy)           β”‚ β”‚
β”‚        β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚              πŸ”§ CodexServerManager                 β”‚  β”‚
β”‚  β”‚  Bootstrap β†’ Node.js β†’ Codex CLI β†’ Platform Binary β”‚  β”‚
β”‚  β”‚  Config β†’ Proxy β†’ Auth β†’ Health Check β†’ Server     β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚        β”‚                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚              🐧 Embedded Linux ($PREFIX)           β”‚  β”‚
β”‚  β”‚                                                    β”‚  β”‚
β”‚  β”‚  node (v24)  ─── Express server (:18923)           β”‚  β”‚
β”‚  β”‚                      β”‚                             β”‚  β”‚
β”‚  β”‚                      β”œβ”€β”€ JSON-RPC over stdio       β”‚  β”‚
β”‚  β”‚                      β–Ό                             β”‚  β”‚
β”‚  β”‚  codex app-server (native Rust/musl aarch64)       β”‚  β”‚
β”‚  β”‚       β”‚                                            β”‚  β”‚
β”‚  β”‚       β”œβ”€β”€ HTTPS_PROXY ──▢ proxy.js (:18924)        β”‚  β”‚
β”‚  β”‚       β”‚                      β”‚                     β”‚  β”‚
β”‚  β”‚       β”‚                      β–Ό                     β”‚  β”‚
β”‚  β”‚       β”‚                 api.openai.com             β”‚  β”‚
β”‚  β”‚       β”‚                                            β”‚  β”‚
β”‚  β”‚       └── SSE notifications ──▢ WebView            β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”„ Request Lifecycle

User taps Send
  β†’ πŸ–₯️ Vue ThreadComposer β†’ useDesktopState β†’ codexGateway
    β†’ πŸ“‘ POST /codex-api/rpc { method: "turn/start" }
      β†’ πŸ”Œ Express bridge β†’ JSON-RPC stdin β†’ codex app-server
        β†’ πŸ¦€ Native Rust binary β†’ HTTPS via proxy β†’ OpenAI API
        β†’ πŸ“€ stdout JSON-RPC notifications (streaming)
      β†’ πŸ“Ί SSE EventSource β†’ live typing in WebView

πŸ“ Project Structure

πŸ€– codex-app-android/
β”œβ”€β”€ πŸ“± android/
β”‚   β”œβ”€β”€ πŸ”§ app/build.gradle.kts           # targetSdk=28 (W^X bypass)
β”‚   └── πŸ“‚ src/main/
β”‚       β”œβ”€β”€ πŸ“‹ AndroidManifest.xml         # Permissions & service declaration
β”‚       β”œβ”€β”€ πŸ“¦ assets/
β”‚       β”‚   β”œβ”€β”€ 🌐 proxy.js               # Node.js CONNECT proxy
β”‚       β”‚   └── 🎁 server-bundle/         # Pre-built Vue + Express + deps
β”‚       └── β˜• java/com/codex/mobile/
β”‚           β”œβ”€β”€ 🐧 BootstrapInstaller.kt   # Linux environment setup
β”‚           β”œβ”€β”€ πŸ”” CodexForegroundService.kt # Background persistence
β”‚           β”œβ”€β”€ βš™οΈ CodexServerManager.kt    # Install, auth, proxy, server
β”‚           └── πŸ–₯️ MainActivity.kt         # WebView + setup orchestration
β”œβ”€β”€ 🌐 src/                                # codex-web-local (TypeScript + Vue)
β”‚   β”œβ”€β”€ πŸ“‘ api/                            # RPC client, gateway, SSE
β”‚   β”œβ”€β”€ 🧩 components/                     # Vue components (composer, threads)
β”‚   β”œβ”€β”€ πŸ”— composables/                    # useDesktopState (reactive state)
β”‚   β”œβ”€β”€ πŸ”Œ server/                         # Express + codex app-server bridge
β”‚   └── πŸš€ cli/                            # CLI entry point
β”œβ”€β”€ πŸ”§ android/scripts/
β”‚   β”œβ”€β”€ πŸ“₯ download-bootstrap.sh           # Fetch Termux bootstrap
β”‚   └── πŸ“¦ build-server-bundle.sh          # Bundle frontend into APK
└── πŸ“– PROJECT_SPEC.md                     # Full technical specification

🧩 How It Works

They said you can't run a statically-linked Rust binary on Android without root. We did it anyway.

🐧 Embedded Linux Environment

The APK bundles Termux's bootstrap-aarch64.zip β€” a minimal Linux userland with sh, apt-get, dpkg-deb, SSL certificates, and core libraries. On first launch, it's extracted to the app's private storage. All hardcoded /data/data/com.termux/ paths are rewritten to our package path.

πŸ¦€ Native Codex Binary

The Codex CLI ships a 73MB native Rust binary compiled for aarch64-unknown-linux-musl. npm refuses to install it on Android (os: "linux" vs process.platform: "android"), so we download the tarball directly from the npm registry using Node.js and extract it manually.

🌐 DNS/TLS Proxy Bridge

The musl-linked binary reads /etc/resolv.conf for DNS β€” which doesn't exist on Android. Our Node.js CONNECT proxy on port 18924 solves this: Node.js uses Android's native Bionic DNS resolver, and the native binary routes all HTTPS through HTTPS_PROXY.

πŸ”Œ JSON-RPC Stdio Bridge

The Express server spawns codex app-server and communicates via newline-delimited JSON-RPC 2.0 over stdin/stdout. Notifications stream back via Server-Sent Events to the Vue frontend, enabling real-time typing, reasoning visibility, and turn progress.


πŸ›‘οΈ Security & Permissions

Permission Why
🌐 INTERNET API calls to OpenAI
πŸ”” FOREGROUND_SERVICE Keep server alive in background
πŸ”‹ REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Prevent Doze from killing processes
πŸ”’ WAKE_LOCK Maintain CPU during long tasks

The app runs with targetSdk = 28 to bypass Android 10+'s W^X (Write XOR Execute) SELinux policy β€” same approach used by Termux on F-Droid.


🎯 Requirements

  • πŸ“± Android 7.0+ (API 24) β€” ARM64 device
  • 🌐 Internet connection β€” for first-run setup + API calls
  • πŸ”‘ OpenAI account β€” authenticated via OAuth browser flow
  • πŸ’Ύ ~500MB storage β€” for Linux environment + Node.js + Codex binary

πŸ› Troubleshooting

Problem Solution
🚫 App crashes on launch Check adb logcat for CodexServerManager errors
πŸ”’ "Permission denied" executing binaries Ensure targetSdk = 28 in build.gradle.kts
🌐 "No address associated with hostname" Check device has internet; proxy may not be running
πŸ”‘ Login page doesn't open Ensure a default browser is set on the device
πŸ“¦ Old UI after APK update Server bundle re-extracts every launch β€” force-stop and reopen
πŸ”‹ App killed in background Grant battery optimization exemption in Android settings
πŸ’₯ codex exec fails with "not inside trusted directory" Uses --skip-git-repo-check flag automatically

πŸ“Š Tech Stack

Layer Technology Version
πŸ€– AI Engine OpenAI Codex CLI (@openai/codex) 0.104.0
πŸ¦€ Native Binary Rust (musl, aarch64) -
🟒 Runtime Node.js (via Termux) 24.13.0
🌐 Frontend Vue.js 3 + Vite + TailwindCSS 3.x
πŸ”Œ Backend Express.js + JSON-RPC bridge -
πŸ“± Android Kotlin + WebView 2.1.0
🐧 Linux Termux bootstrap (aarch64) -

⭐ Star This Repo

If you believe an AI coding agent should run in your pocket β€” not just on a laptop with a terminal β€” smash that star button. ⭐

This is what happens when you refuse to accept "it's desktop-only."

Star History


Built by shoving an entire Linux distro into an APK and refusing to give up πŸ”¬

They said "just use SSH to your server." We said "no." 😏

About

🦞 AnyClaw β€” OpenClaw + Codex CLI running natively on Android. Two AI agents in one APK. No root. No Termux. Embedded Linux + Node.js + Rust + Vue.js.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages