📌 How to Install and Set Up Android Studio on Ubuntu via Command Line
Android Studio is the official IDE for Android development. In this guide, we'll walk through installing and setting up Android Studio on Ubuntu using the command line.
🚀 1. Install Java Development Kit (JDK)
✅ Check if JDK is Installed
Before installing, check if JDK is already installed:
java -version
If not installed, proceed with the steps below.
🔹 Install OpenJDK 11 (Recommended)
sudo apt update
sudo apt install openjdk-11-jdk -y
🔹 Verify Installation
java -version
Expected output:
openjdk version "11.0.x" 2024-XX-XX
🔹 Set JAVA_HOME Environment Variable
echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64' >> ~/.bashrc
source ~/.bashrc
🔥 2. Download and Install Android Studio
✅ Download Android Studio
wget -O android-studio.tar.gz "https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2024.1.1.0/android-studio-2024.1.1.0-linux.tar.gz"
🔹 Extract and Move to /opt/
Directory
tar -xvf android-studio.tar.gz
sudo mv android-studio /opt/
🔹 Run Android Studio Setup
/opt/android-studio/bin/studio.sh
🔧 3. Add Android Studio to PATH
To run studio.sh
from anywhere, create a symbolic link:
sudo ln -s /opt/android-studio/bin/studio.sh /usr/local/bin/android-studio
Now, you can start Android Studio by running:
android-studio
📱 4. Set Up Android Emulator (AVD)
✅ Install Required Packages
sudo apt update
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils -y
🔹 Check KVM Support
egrep -c '(vmx|svm)' /proc/cpuinfo
If the output is 0
, your CPU does not support virtualization.
🔹 Grant User Permissions for KVM
sudo usermod -aG kvm $USER
sudo usermod -aG libvirt $USER
newgrp kvm
🔹 Launch Android Virtual Device (AVD) Manager
android-studio
- Go to
Tools
>Device Manager
. - Click
Create Virtual Device
. - Select a device model and download a system image.
- Configure the settings and start the emulator.
🎯 Conclusion
Now you have installed Android Studio, set up JDK, and configured the Android Emulator using command-line steps. Happy coding! 🚀