Build and install Android APKs entirely from Termux -- no Android Studio, no computer, just your phone.
This is a minimal Hello World app that demonstrates the complete build pipeline: resource compilation, Java compilation, DEX conversion, APK packaging, and signing.
- Android device with Termux installed
- Java (JDK) installed in Termux:
pkg install openjdk-21
# Clone the repo
git clone https://github.com/azmaveth/termux-android-hello.git
cd termux-android-hello
# Install build tools and download android.jar
bash setup.sh
# Grant storage access (needed once for installing APKs)
termux-setup-storage
# Build the APK
bash build.sh
# Install on device
cp build/apk/app.apk ~/storage/shared/ && termux-open ~/storage/shared/app.apk| Package | Purpose |
|---|---|
aapt2 |
Android resource compiler and linker |
apksigner |
APK signing tool |
dx |
Java bytecode to DEX converter |
zip |
APK packaging |
It also downloads the Android SDK platform JAR (android.jar from API 33) which provides the Android framework classes, and generates a debug signing keystore.
The build follows the standard Android build process, just without Gradle:
res/*.xml ──> aapt2 compile ──> *.flat
│
AndroidManifest.xml ──> aapt2 link ──> unsigned.apk + R.java
│
*.java + R.java ──> javac ──> *.class ──> dx ──> classes.dex
│
unsigned.apk + classes.dex ──> zip ──> apksigner ──> signed.apk
.
├── AndroidManifest.xml # App manifest
├── build.sh # Build script
├── setup.sh # One-time setup (installs tools)
├── res/
│ ├── layout/activity_main.xml # UI layout
│ └── values/strings.xml # String resources
└── src/
└── com/example/hello/
└── MainActivity.java # App code
- Java 8 bytecode only (uses
dxinstead ofd8due to a JDK 21 compatibility issue) - No dependency management (no Gradle/Maven)
- No AndroidX/Jetpack libraries (framework APIs only)
- No ProGuard/R8 minification
- No Compose -- XML layouts only
These limitations aside, this approach works well for utility apps, prototypes, personal tools, and learning Android fundamentals.
- Change the package name in
AndroidManifest.xmland the directory structure undersrc/ - Update
build.shto point to your new package/class paths - Add your layouts in
res/layout/and strings inres/values/ - Write your Java code -- any Android framework API is available
MIT