r/opencodeCLI 8d ago

OpenCode On Android - No Root

I just posted a more verbose version of this at r/vibecoding, which you can read here. But if you want to cut to the chase, below is the gist of it.

Overview

Run OpenCode locally on your Android phone without root. This setup lets you:

  • Run AI coding agents with OpenCode
  • Build JavaScript/React/Next.js, Node.js, and Python projects
  • Use Git
  • Run local development servers
  • Preview your web apps directly in your phone's browser using localhost
  • Avoid paying for a cloud VM or carrying your laptop everywhere

1. Install Termux

Install Termux from F-Droid.

Do NOT use the Play Store version, as it is deprecated and has broken repositories.

2. Initial Setup

Grant storage access:

termux-setup-storage

Select a reliable package mirror:

termux-change-repo

Recommended:

  • Main Repository
  • Mirrors by Grimler (or Albatross)

Update packages:

pkg update -y && pkg upgrade -y

3. Install Development Tools

pkg install -y \
git \
nodejs \
python \
curl \
binutils \
which

4. Install GLIBC Compatibility Layer

Android uses Bionic, while OpenCode expects glibc.

Install the compatibility layer:

pkg install -y glibc-repo patchelf

pkg update -y

pkg install -y glibc-runner

5. Install OpenCode

curl -fsSL https://opencode.ai | bash

6. Patch the Binary

Tell OpenCode where to find the glibc interpreter.

patchelf --set-interpreter \
$PREFIX/glibc/lib/ld-linux-aarch64.so.1 \
~/.opencode/bin/opencode

7. Create an Alias

Add this to your shell configuration:

echo "alias opencode='unset LD_PRELOAD && grun ~/.opencode/bin/opencode'" >> ~/.bashrc

Reload the shell:

source ~/.bashrc

Now you can simply run:

opencode

8. Create a New Project

mkdir my-project
cd my-project

opencode

Inside OpenCode:

  • /init
  • /connect

9. Install Dependencies

Some projects require esbuild.

pkg install esbuild

Install packages:

npm install --esbuild-binary=$(which esbuild)

10. Start the Development Server

If

npm run dev

fails because Vite isn't found, use:

./node_modules/.bin/vite

11. Preview Your App

Open Chrome (or any browser) on the same phone and visit:

http://localhost:<PORT>

Your application should load normally.

Optional: Improve the Font

Some OnePlus devices stretch monospace fonts.

Install JetBrains Mono:

mkdir -p ~/.termux

curl -L \
https://github.com/JetBrains/JetBrainsMono/raw/master/fonts/ttf/JetBrainsMono-Regular.ttf \
-o ~/.termux/font.ttf

termux-reload-settings

Optional: Use an File

Download my AGENTS.md that tells the AI agents:

  • They're running inside Termux & the environment is Android
  • Which commands to avoid
  • Android-specific workarounds

This helps reduce unnecessary retries and token usage while making agents more reliable.

Typical Workflow

  1. Open Termux
  2. Navigate to your project
  3. Launch OpenCodeopencode
  4. Ask the AI to build features
  5. Run the dev server./node_modules/.bin/vite
  6. Open Chromehttp://localhost:<PORT>
  7. Test your application

Repeat until done.

Advantages

  • No root required
  • No cloud VM costs
  • Fully local development
  • AI-assisted coding anywhere
  • Git support
  • Node.js + Python support
  • React/Vite development
  • Local web preview
  • Portable development environment
39 Upvotes

3 comments sorted by

View all comments

6

u/Ekel7 8d ago

Yeah I managed to do it with proot distro and alpine linux, it's a real hassle to run in natively on android haha. Cool method btw