Programming

Build an APK on a phone: Termux and Gradle

A debug APK without a computer. This file does not go to Play. It is for testing on the phone.

All lessons · JavaScript lessons: learn from scratch

Tools in Termux

You can build a debug APK on a phone without a computer. It is not the store file. Play wants a signed AAB. app-debug.apk is only for installing on your own phone and testing. First you need Node.js, git and Java. If Java is missing, Gradle stops.

pkg update && pkg upgrade -y
pkg install nodejs git openjdk-17 -y
java -version

The project and the APK

Clone the project, install the packages, and add Capacitor if it is missing. npm run build packs the web files. npx cap sync moves them into the Android folder. Then, inside android, run ./gradlew assembleDebug. The first time, Gradle downloads the SDK from the internet. It can take several minutes. After BUILD SUCCESSFUL the file is here: android/app/build/outputs/apk/debug/app-debug.apk

git clone https://github.com/istifadeci/proyekt-adi.git
cd proyekt-adi
npm install
npm install @capacitor/core @capacitor/cli @capacitor/android
npx cap init
npx cap add android
npm run build
npx cap sync
cd android
./gradlew assembleDebug

Questions

What does Java not found mean? The JAVA_HOME path is missing. In Termux, export the default-jvm path and run the command again.

Why does the build stop halfway? The first Gradle downloads large files. If the internet drops, the process stops. The network must stay up.

Why does storage fill up? The SDK and Gradle take about 1–2 GB. If free space is low, the build does not finish. This APK is not uploaded to Play.

export JAVA_HOME=/data/data/com.termux/files/usr/lib/jvm/default-jvm

Author: Nibras Code