Skip to content

Instantly share code, notes, and snippets.

@tmatz
Last active November 17, 2024 19:19
Show Gist options
  • Save tmatz/817bf03433e059bf89c63dc33f286ccb to your computer and use it in GitHub Desktop.
Save tmatz/817bf03433e059bf89c63dc33f286ccb to your computer and use it in GitHub Desktop.
Build android app on termux

Build android app on termux

1. install termux

install termux from F-Droid.

2. setup termux

apt update
apt upgrade
# source.list changed
apt update
termux-setup-storage

3. install ubuntu

apt install git wget proot
git clone https://github.com/MFDGaming/ubuntu-in-termux.git
cd ubuntu-in-termux
# install ubuntu
bash ubuntu.sh -y
# fix PATH order
sed -Ei 's|(:/bin)(:/usr/bin):|\2\1:|' startubuntu.sh
# start
./startubuntu.sh

4. install packages for build

Now, in ubuntu.

apt update
apt upgrade
apt install default-jdk-headless openjdk-8-jdk-headless unzip aapt2

5. install android cmdline-tools and platforms

Download Android Command Line Tools for Linux from https://developer.android.com/studio

cd ~
unzip /sdcard/Download/commandlinetools-linux-9477386_latest.zip
export ANDROID_HOME=$HOME/android/sdk
mkdir -p $ANDROID_HOME/cmdline-tools
mv cmdline-tools $ANDROID_HOME/cmdline-tools/latest
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
# just for fix broken dependencies
JAVA_OPTS=-Dos.arch=amd64 sdkmanager emulator
# install target platforms
sdkmanager 'platforms;android-26'

5. replace aapt2

cd project-dir
echo "sdk.dir=$ANDROID_HOME" > local.properties
alias gradlew='JAVA_HOME=/usr/lib/jvm/java-8-openjdk-arm64 bash ./gradlew'
# first build should fail. it is for downloading aapt2-*-linux.jar
gradlew
# replace aapt2 binary for arm64
find ~/.gradle -name 'aapt2-*-linux.jar' -type f | xargs -I{} jar -u -f {} -C /usr/bin aapt2

6. build apk!

cd project-dir
gradlew
@mishpro-programm
Copy link

😳

@Siddhesh2377
Copy link

What about.abb

@aliel0malki
Copy link

💀

@josephwilmer
Copy link

Hello! I've been reading Zenbit Tech blog for a couple of weeks now and thought I'd finally comment on one of their articles. I like the idea of creating an app to help protect data on AWS Architecture Areas using the encryption method—I think it would be a good fit for me because I'm a web developer and have experience working with Amazon Web Services (AWS). It would also be something that I could do with my current skills, so I don't have to take time away from my day job to learn new things.

@Tanzin01
Copy link

Getting error with this "apt install default-jdk-headless openjdk-8-jdk-headless unzip aapt2"

Apt2 don't exist something

@JohnScience
Copy link

Getting error with this "apt install default-jdk-headless openjdk-8-jdk-headless unzip aapt2"

Apt2 don't exist something

Same problem.

When I tried to follow with the instructions regardless, gradlew silently failed, claiming that the build completed successfully.

@SaCald
Copy link

SaCald commented Jul 13, 2023

I get error: "/android-sdk/bin/java not found" when I run "gradlew", but the file is in /android-sdk/bin. I try chmod a+rwx, but it still doesn't work.

@SaCald
Copy link

SaCald commented Jul 13, 2023

If you want to create apps on Android, you can use this
https://github.com/itsaky/AndroidIDE
It's not an advertisement, I just want to help people, who doesn't have 64 bit system. Because i see, that some people couldn't create app with method in the top of the thread(of the page)

@Stonar93
Copy link

No such file or directory

@Git2020104
Copy link

If you want to create apps on Android, you can use this https://github.com/itsaky/AndroidIDE It's not an advertisement, I just want to help people, who doesn't have 64 bit system. Because i see, that some people couldn't create app with method in the top of the thread(of the page)

Oh good but it requires a phone with substantial ram

@vikramisdev
Copy link

If you want to create apps on Android, you can use this https://github.com/itsaky/AndroidIDE It's not an advertisement, I just want to help people, who doesn't have 64 bit system. Because i see, that some people couldn't create app with method in the top of the thread(of the page)

Oh good but it requires a phone with substantial ram

In that case you can use CodeAssist, either the official one or the unofficial Deenu's CodeAssist. (This one recommended)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment