Install Android Studio in Termux
Requirements
- Download and install Termux from F-Droid
- Install Ubuntu using this repository: ubuntu-on-android
- VNC Viewer must be installed for GUI mode
Login to Ubuntu (Udroid)
Login using the predefined user hippo:
proot-distro login --user hippo udroid-focal-xfce4 --shared-tmp --bind /dev/null:/proc/sys/kernel/cap_last_cap
Install Java Development Kit
Update repositories and install JDK 11:
sudo apt update
sudo apt install openjdk-11-jdk -y
Start GUI Mode
Make sure VNC Viewer is installed on your device, then run:
vncserver :1
Set Up Android Studio
Download the Android Studio Linux tar package from: developer.android.com
Download Android SDK, JDK, and AAPT2 according to your device architecture from: androidide.com
Move all downloaded files to the $HOME directory.
Note: Android 12 devices may have pointer issues with JDK. In this case, use 32-bit build tools.
Extract Files and Configure Environment
Extract Android Studio, Android SDK, JDK, and AAPT2 inside $HOME.
Edit the Bash configuration file:
nano ~/.bashrc
Add the following lines:
export ANDROID_SDK_ROOT=$HOME/android-sdk
export GRADLE_USER_HOME=$HOME/.gradle
Save the file and apply changes:
source ~/.bashrc
Run Android Studio
bash android-studio/bin/studio.sh
Make sure Java version is 11:
java --version
Android Studio Setup Notes
- Select JDK path:
/home/hippo/jdk - Do not download the emulator (uncheck it)
- Select Android SDK path:
/home/hippo/android-sdk
Proceed with the setup. If everything is correct, required components will be downloaded. Click Finish after completion.
Project Configuration (For 32-bit Build Tools)
Edit gradle.properties:
org.gradle.jvmargs=-Xmx1024m
Edit build.gradle (Project level):
classpath "com.android.tools.build:gradle:7.0.2"
Edit build.gradle (App level):
compileSdkVersion 31
Build the project after making these changes.
Notes
- Layout Manager is not working
- If you encounter errors, search them before retrying
Sources
- Android SDK, JDK, AAPT2: AndroidIDE
- Ubuntu on Android: ubuntu-on-android
- Termux: termux.com
Hope you did it 👍🏻