In this tutorial, you'll learn how to build APKs with Termux, without needing Proot.
Note
This guide assumes familiarity with Termux and Gradle basics. The steps below will help you get set up quickly.
After facing challenges in building apps and testing multiple methods, I've put together the best way to do it. You can use the automated setup script or follow the manual steps below.
The fastest way to set up your build environment is using the automated setup script:
# Download and run the setup script
wget -O ~/termux-setup.sh https://raw.githubusercontent.com/illegalvoid/termux-build-apps/main/setup.sh
chmod +x ~/termux-setup.sh
bash ~/termux-setup.shAfter the script completes, restart your terminal or run:
source ~/.bashrcThe script will automatically:
- Update Termux packages
- Install Java 21 (latest LTS)
- Install Android SDK
- Accept SDK licenses
- Install Android Platform API 35
- Install Gradle 8.10.2 (latest stable)
- Configure aapt2 path
- Set up all environment variables
If you prefer to set things up manually, follow these steps:
Termux is a powerful terminal app for Android, and it will serve as your development environment.
Before setting up the Android SDK, you'll need some essential packages in Termux. This tutorial uses Java 21 (latest LTS version).
# First update & upgrade
pkg update -y && pkg upgrade -y
# Then install jdk and wget
pkg install wget openjdk-21 -ySimple Check (JDK):
To confirm Java is installed correctly, run:java -versionIt should output information about JDK version 21.
Next, we need the Android SDK. You can find setup in this repository, or run the following commands directly:
# Download the installer script using wget and save it to the home directory
wget -O ~/install-android-sdk.sh https://raw.githubusercontent.com/Sohil876/termux-sdk-installer/main/installer.sh
# Make the script executable
chmod +x ~/install-android-sdk.sh
# Run the script with the install option
bash ~/install-android-sdk.sh -iOnce the SDK is installed, you'll see a new directory named android-sdk in your Termux files. This directory contains all necessary tools.
Before moving on, you must accept Google licenses:
yes | sdkmanager --licensesSet the Android platform version to latest, which is 35 (Android 15):
yes | sdkmanager "platforms;android-35"You'll need Gradle v8.10.2 (latest stable version), which is compatible with Java 21. Download and set it up as follows:
# Download Gradle
wget -O $ANDROID_HOME/gradle-8.10.2-bin.zip https://services.gradle.org/distributions/gradle-8.10.2-bin.zip
# Unzip it
unzip $ANDROID_HOME/gradle-8.10.2-bin.zip -d $ANDROID_HOME/
mv $ANDROID_HOME/gradle-8.10.2/ $ANDROID_HOME/gradle/
# Remove zip file (optional)
rm $ANDROID_HOME/gradle-8.10.2-bin.zip
# Add Gradle to your PATH
echo 'export PATH=${PATH}:${ANDROID_HOME}/gradle/bin' >> ~/.bashrc
source ~/.bashrcNow you can run Gradle and the Android SDK for any task you need.
Simple Check (Gradle):
To verify Gradle is working, run:gradle -vIt should show version info such as:
Gradle 8.10.2
There's a known issue with Gradle in Termux where it cannot find the aapt2 build tool. To fix this, specify it in the global Gradle properties.
Go to the file ~/.gradle/gradle.properties (create it if it doesn't exist) and add:
android.aapt2FromMavenOverride=/data/data/com.termux/files/home/android-sdk/build-tools/<version>/aapt2Replace <version> with the actual version you have in your SDK (you can find it by running ls ~/android-sdk/build-tools/).
- Java: OpenJDK 21 (LTS)
- Gradle: 8.10.2 (latest stable)
- Android Platform: API 35 (Android 15)
- Build Tools: Latest available via SDK Manager
If you encounter any issues:
- Gradle daemon issues: Run
gradle --stopand try again - Permission errors: Make sure all scripts have execute permissions with
chmod +x - Path issues: Ensure you've run
source ~/.bashrcafter installation - Build failures: Check that your project's
build.gradletargets compatible SDK versions
Congratulations! You can now build Android apps using Termux, without Proot. Enjoy coding!