Chạy Claude Code trên Android qua proot-distro
Đăng ngày 21/7/2026
Anthropic không hỗ trợ Android. Nhưng vẫn chạy được, qua một lớp Ubuntu trong proot.
Vấn đề
Claude Code là binary linux-arm64 link động với glibc. Termux chạy trên bionic libc của Android. Cài thẳng bằng npm sẽ có lỗi:
Unsupported platform: android arm64
Cách work around: dựng một Ubuntu rootfs trong Termux bằng proot-distro, có glibc thật, rồi cài Claude Code trong đó.
Yêu cầu
- Máy aarch64, Android 8+ - kiểm tra bằng
uname -m - Termux cài từ F-Droid (bản Play Store đã ngừng cập nhật)
- ~2GB trống
Cài
Trong Termux:
pkg update -y && pkg upgrade -y
pkg install proot-distro -y
proot-distro install ubuntu
proot-distro login ubuntu
Trong Ubuntu:
apt update && apt install -y curl git
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs
npm install -g @anthropic-ai/claude-code
claude
Lần đầu chạy claude sẽ mở luồng đăng nhập trình duyệt. Dùng tài khoản Claude có sẵn, không cần API key.
Alias cho tiện
Thêm vào ~/.bashrc của Termux, không phải của Ubuntu:
alias claude='proot-distro login ubuntu -- bash -lc "claude"'
Từ đó chỉ cần gõ claude.
Noti khi Claude cần chú ý
Claude Code có hook Notification (khi cần permission/input) và Stop (khi xong việc). Gắn termux-notification vào đó, bấm vào noti là quay lại Termux.
Cài (trong Termux, không phải Ubuntu):
pkg install termux-api -y
Và cài thêm app Termux:API từ F-Droid - package termux-api chỉ là script gọi sang app đó qua intent, thiếu app thì lệnh không chạy.
Bấm vào noti không tự mở lại Termux - đây là chỗ tốn thời gian nhất. am start gọi từ action của noti chạy trong background service của Termux:API, và Android 10+ chặn activity-start từ background theo mặc định (Background Activity Launch restriction). Sửa bằng cách cấp quyền overlay cho Termux:
Settings → Apps → Termux → Advanced → Display over other apps → Allow
Không có quyền này thì am start chạy “thành công” (exit 0) nhưng không đưa app lên foreground — dễ tưởng nhầm là sai cú pháp lệnh.
Lệnh dùng full path, vì action của termux-notification chạy trong shell riêng, không có $PATH:
termux-notification --title "Claude Code" --content "..." \
--action "/data/data/com.termux/files/usr/bin/am start --user 0 -n com.termux/com.termux.app.TermuxActivity"
--user 0 bắt buộc - thiếu nó, am của Termux (bản tự viết lại, không phải am thật của Android) ném SecurityException vì thiếu INTERACT_ACROSS_USERS_FULL.
Gắn vào ~/.claude/settings.json trong Ubuntu:
{
"hooks": {
"Notification": [
{ "hooks": [ { "type": "command",
"command": "jq -r '.message // .title // \"Claude needs your attention\"' | { read -r msg; termux-notification --title \"Claude Code\" --content \"$msg\" --action \"/data/data/com.termux/files/usr/bin/am start --user 0 -n com.termux/com.termux.app.TermuxActivity\" --id 42; } 2>/dev/null || true" } ] }
],
"Stop": [
{ "hooks": [ { "type": "command",
"command": "termux-notification --title \"Claude Code\" --content \"Claude stopped — check the session\" --action \"/data/data/com.termux/files/usr/bin/am start --user 0 -n com.termux/com.termux.app.TermuxActivity\" --id 42 2>/dev/null || true" } ] }
]
}
}
Sau khi sửa settings.json, mở /hooks một lần (hoặc mở session claude mới) để nó nạp lại - sửa file khi session đang chạy không tự áp dụng.
Chạy nhiều tab Termux cùng lúc thì noti không tự chọn đúng tab. am start chỉ đưa app Termux lên trước, hiện tab nào đang là “current” - Termux không expose intent nào cho app ngoài chọn một session có sẵn theo tên/ID (đã tra RUN_COMMAND wiki và source, phần session-action chỉ áp dụng lúc tạo session mới). Muốn kiểm soát: gộp các project vào chung một tmux server (mỗi project một window có tên), giữ đúng một tab Termux attach vào đó, rồi cho action của noti chạy tmux select-window -t <tên> trước am start. Chưa kiểm chứng kỹ phần này.
Giới hạn
Đây là workaround, không phải solution chính thức được support.