Install Claude Code on Termux (Android) – Fix Unsupported Platform

I stared at the terminal in disbelief. Termux on my Android tablet was supposed to be a full Linux environment—I had Node.js, Python, even a lightweight desktop. But when I tried npm install -g @anthropic-ai/claude-code, it spat out “Unsupported platform: android arm64” and refused to budge. I tried forcing the install, messing with package.json, even patching the binary. Nothing worked. Until I realized: Claude Code's native binary needs a real glibc Linux environment, and Android's bionic libc just isn't it.

After three hours of trial, error, and reading obscure GitHub issues, I found a method that actually works. It uses proot-distro to create a lightweight Ubuntu sandbox inside Termux, then a tiny wrapper script to let the Claude binary run seamlessly—as if you were on a normal Linux server. The best part? You can edit files right from Termux and Claude will see them in context.

In this guide, I'll walk you through every single step, including the fixes for that dreaded "unexpected e_type" error. By the end, you'll have Claude Code running on your Android phone or tablet, ready to help you write, debug, and refactor code on the go.

Prerequisites

  • Termux from F‑Droid (the Play Store version is outdated and lacks some packages).
  • Node.js installed: pkg install nodejs
  • proot-distro installed: pkg install proot-distro
  • At least 2 GB of free storage (Ubuntu base image + Node modules will eat around 1.5 GB).

Suggested Image: Screenshot of Termux with pkg install commands running.

Step 1: Set Up a Linux Environment

Claude Code expects a standard Linux distribution (glibc). We'll install Ubuntu inside Termux using proot-distro.

# Install Ubuntu
proot-distro install ubuntu

# (Optional) Update the Ubuntu environment
proot-distro login ubuntu -- apt update && apt upgrade -y

This downloads a minimal Ubuntu rootfs. The first login might take a minute. Once done, you can exit back to Termux by typing exit.

Step 2: Install the Claude Code CLI Wrapper (Termux Side)

Even though the native binary won't install directly, we install the main CLI wrapper globally. This gives us the claude command structure but not the actual engine.

npm install -g @anthropic-ai/claude-code

You'll likely see a warning about missing platform support. Ignore it—we'll fix that next.

Step 3: Force Install the Linux ARM64 Binary

Now we manually pull the correct binary package for Linux ARM64 (the same CPU architecture as most Android phones/tablets).

npm install -g @anthropic-ai/claude-code-linux-arm64 --force

The --force flag overrides the platform check and downloads the raw binary. However, it won't place it where the wrapper expects. That's our next job.

Step 4: Create a Fix Script to Link the Binary

We need to copy the downloaded binary into the wrapper's expected location. Create a file named fix-claude.js with the following content:

const fs = require('fs');
const path = require('path');

// Target the global node_modules directory
const baseDir = '/data/data/com.termux/files/usr/lib/node_modules/@anthropic-ai';
const src = path.join(baseDir, 'claude-code-linux-arm64/claude');
const dest = path.join(baseDir, 'claude-code/bin/claude.exe');

// Create the bin directory if it doesn't exist
if (!fs.existsSync(path.dirname(dest))) {
  fs.mkdirSync(path.dirname(dest), { recursive: true });
}

// Copy the binary
fs.copyFileSync(src, dest);
fs.chmodSync(dest, 0o755);
console.log('Claude binary linked successfully!');

Run it with Node.js:

node fix-claude.js

You should see the success message. This places the actual claude engine inside the wrapper's expected path.

Step 5: Create a Termux Wrapper Script (The Magic)

The binary still won't run directly in Termux because of the "unexpected e_type" error (it's a native Linux executable, not an Android PIE binary). We create a shell script that tells proot-distro to execute the binary inside the Ubuntu sandbox—while staying fully aware of your current working directory.

# Create the wrapper
printf '#!/data/data/com.termux/files/usr/bin/bash
proot-distro login ubuntu --work-dir "$(pwd)" -- /data/data/com.termux/files/usr/lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe "$@"\n' > /data/data/com.termux/files/usr/bin/claude

# Make it executable
chmod +x /data/data/com.termux/files/usr/bin/claude

Let me break that down:

  • --work-dir "$(pwd)": Passes your current Termux directory to the Ubuntu sandbox, so Claude can see and edit the same files.
  • Full path to claude.exe: Points directly to the binary we just linked.
  • "$@": Forwards any extra arguments you type, like --help or a prompt.

Suggested Image: Screenshot of the wrapper script being created.

Step 6: Authenticate and Start Using Claude Code

Everything is set. Now simply run:

claude --version

If everything worked, you'll see the version number. Then start an interactive session:

claude

On the first run, it will display a login link. Copy that link (long‑tap in Termux) and open it in your mobile browser to authenticate your Anthropic account. Once authorized, you're in.

Why This Setup Works

  • The Binary: We're using the linux-arm64 build because most ARM‑based Android devices share the same instruction set as ARM Linux servers.
  • proot-distro: It provides a glibc environment and kernel‑emulation layers. This lets standard Linux executables run on Android's non‑standard (bionic) libc.
  • The Wrapper: By using --work-dir "$(pwd)", Claude Code remains context‑aware. You can navigate to your project folder in Termux and Claude will operate on those files directly—no copy‑pasting needed.

Troubleshooting Common Errors

"Unsupported platform: android arm64" during npm install

This is normal. The wrapper sees android and refuses to download the native binary. Using --force on the linux‑arm64 package bypasses this. Then our fix‑claude.js script places it correctly.

"Exec format error" or "unexpected e_type"

This means you tried to run the binary directly in Termux. You must use the wrapper script that passes execution through proot-distro. Verify the wrapper exists at /data/data/com.termux/files/usr/bin/claude and is executable.

Permission denied when running fix-claude.js

Make sure you are in a directory where you have write permissions (your home is fine). If /data/data/... paths need root, double‑check that Termux was installed from F‑Droid (it runs as the standard com.termux user, so those paths should be writable).

Claude can't see my files

Ensure you're running claude from the same directory where your project lives. The wrapper passes $(pwd) to the sandbox. If you moved folders after starting, restart the session.

Frequently Asked Questions

Does this drain battery fast?

Running a full Ubuntu sandbox and a large language model CLI will use more CPU than a typical app. Expect noticeable battery drain during heavy use. A 45‑minute coding session on a mid‑range tablet dropped my battery from 80% to about 55%. Keep a charger handy.

Can I use this on a phone or only on tablets?

Both work. The screen size may be cramped on a phone for extended coding, but with an external keyboard (Bluetooth or USB‑C) it's perfectly usable. The installation steps are identical.

Does this require root access?

No. Termux from F‑Droid runs without root, and proot-distro uses user‑space emulation. Everything lives under /data/data/com.termux/files/, which your normal Termux user owns.

Can I use my existing Anthropic API key?

Yes. After first login, Claude Code stores an OAuth token. Alternatively, you can set ANTHROPIC_API_KEY as an environment variable inside the wrapper (by adding export ANTHROPIC_API_KEY=your_key before the proot-distro line).


Further Reading and Related Posts

Over to You

Have you tried running AI coding assistants on a mobile device? I'm still surprised by how well this works—editing Markdown files and running simple Python scripts feels almost like a desktop. If you hit any snags or found a cleaner method, drop a comment. I'd genuinely like to hear how it went.

Found this helpful? Share it with a developer friend who always says "I can't code on my phone." They can now.

Comments