DEV Community

Mayank Tamrkar
Mayank Tamrkar

Posted on

How to install android studio in linux/ubantu

πŸ“Œ 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
Enter fullscreen mode Exit fullscreen mode

If not installed, proceed with the steps below.

πŸ”Ή Install OpenJDK 11 (Recommended)

sudo apt update
sudo apt install openjdk-11-jdk -y
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Verify Installation

java -version
Enter fullscreen mode Exit fullscreen mode

Expected output:

openjdk version "11.0.x" 2024-XX-XX
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Set JAVA_HOME Environment Variable

echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64' >> ~/.bashrc
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

πŸ”₯ 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"
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Extract and Move to /opt/ Directory

tar -xvf android-studio.tar.gz
sudo mv android-studio /opt/
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Run Android Studio Setup

/opt/android-studio/bin/studio.sh
Enter fullscreen mode Exit fullscreen mode

πŸ”§ 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
Enter fullscreen mode Exit fullscreen mode

Now, you can start Android Studio by running:

android-studio
Enter fullscreen mode Exit fullscreen mode

πŸ“± 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
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Check KVM Support

egrep -c '(vmx|svm)' /proc/cpuinfo
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Launch Android Virtual Device (AVD) Manager

android-studio
Enter fullscreen mode Exit fullscreen mode
  1. Go to Tools > Device Manager.
  2. Click Create Virtual Device.
  3. Select a device model and download a system image.
  4. 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! πŸš€

Top comments (0)