Skip to content

🔐 Login Required

Credits: This tutorial is adapted and enhanced based on original work by zryyoung on GitHub.
All rights reserved. For personal and non-commercial use only.

Termux + Acode Android Project Build and Installation Guide

This guide explains how to build, debug, and install Kotlin/Java projects on Android using Termux / ZeroTermux + Acode.


1. Install Required Tools

Install Termux or ZeroTermux

It is recommended to use ZeroTermux for better compatibility. Download it from its official site or GitHub.

Install Acode Editor

Download Acode from Google Play or its GitHub page.

Install Acode Plugin: acodex-terminal

Open Acode settings, search and install the acodex-terminal plugin.


2. Configure ZeroTermux Environment

Open Termux and run:

pkg update && pkg upgrade -y

Install the acodex-server backend:

curl -sL https://raw.githubusercontent.com/bajrangCoder/acode-plugin-acodex/main/installServer.sh | bash

For older versions, start the service manually each time Termux restarts:

acodex-server &

Newer versions:

axs

To stop the server:

kill axs/acodex-server  # then press TAB and Enter

Enable auto-start using termux-services:

#!/data/data/com.termux/files/usr/bin/sh

# Create service directory
mkdir -p /data/data/com.termux/files/usr/var/service/axs

# Write run file
cat > /data/data/com.termux/files/usr/var/service/axs/run <<EOF
#!/data/data/com.termux/files/usr/bin/sh
exec axs
EOF

# Make it executable
chmod +x /data/data/com.termux/files/usr/var/service/axs/run

# Enable service
sv-enable axs

# Exit terminal
exit  # Then reopen

In Acode, press Ctrl + K to open the terminal panel.


3. Install Android Build Tools

In Termux, install dependencies:

pkg install termux-services wget aapt aapt2 openjdk-17 gradle -y

4. Install Android NDK and SDK

  • NDK:

    wget https://github.com/lzhiyong/termux-ndk/releases/download/android-ndk/android-ndk-r27b-aarch64.zip
    

  • SDK:

    wget https://github.com/lzhiyong/termux-ndk/releases/download/android-sdk/android-sdk-aarch64.zip
    

Extract to a specified directory:

unzip android-ndk-r27b-aarch64.zip -d $PREFIX/opt
unzip android-sdk-aarch64.zip -d $PREFIX/opt

Optionally remove zip files:

rm -rf *.zip

5. Configure Environment Variables

Edit your config:

nano ~/.zshrc

Add:

export NDK_HOME=/data/data/com.termux/files/usr/opt/android-ndk-r27b
# export PATH=$PATH:$NDK_HOME

export ANDROID_SDK_ROOT=/data/data/com.termux/files/usr/opt/android-sdk
export PATH=$PATH:/data/data/com.termux/files/usr/opt/gradle/gradle-8.14/bin/:$NDK_HOME:$ANDROID_SDK_ROOT/tools/:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/build-tools

# Auto-start acodex-server
sudo ps aux | grep "acodex-server" | grep -v grep > /dev/null || acodex-server &

Save with Ctrl + S, exit with Ctrl + X.

Reload config:

source ~/.zshrc

6. Create APK Auto Install Script

Create a file:

nano install.sh

Paste the following:

#!/bin/bash

PROJECT_PATH="$(pwd)"
APK_PATH="${PROJECT_PATH}/app/build/outputs/apk/debug/app-debug.apk"

if [ -f "$APK_PATH" ]; then
    echo "APK found: $APK_PATH, starting installation..."
    termux-open "$APK_PATH"
    if [ $? -eq 0 ]; then
        echo "Installation request sent."
    else
        echo "Failed to call package installer."
        exit 1
    fi
else
    echo "APK file not found."
    exit 1
fi

Make it executable:

chmod +x install.sh

7. Set Acode Default Build Command

In Acode settings > Default Commands:

{
  "extension": "gradle",
  "name": "Gradle",
  "command": "gradle build; bash $HOME/install.sh"
}

8. Fix Build Errors (aapt2 Issue)

If you encounter aapt2 errors, patch with Termux-installed version:

find ~/.gradle -name 'aapt2-*-linux.jar' -type f | xargs -I{} jar -uvf {} -C /data/data/com.termux/files/usr/bin aapt2

Conclusion

Now you can: - Write Kotlin/Java projects using Acode - Build them with Gradle - Install and test APKs on your device

Recommended tools: Termux + Acode + Mixplorer (file manager)