DEV Community

Cover image for Setting Up Android Studio on Linux
Sahil Verma
Sahil Verma

Posted on

Setting Up Android Studio on Linux

Android development on Linux is straightforward and provides a powerful platform for app creation. This guide will walk you through installing Android Studio, Java Development Kit (JDK), and setting up necessary environment variables.

1. Installing Android Studio

Android Studio is the official Integrated Development Environment (IDE) for Android app development. Here's how to install it on Linux:

a) Update your package lists:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

b) Install required dependencies:

sudo apt install default-jdk libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
Enter fullscreen mode Exit fullscreen mode

c) Download Android Studio:

wget https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2023.1.1.26/android-studio-2023.1.1.26-linux.tar.gz
Enter fullscreen mode Exit fullscreen mode

d) Extract the downloaded archive:

sudo tar -xvzf android-studio-*.tar.gz -C /opt/
Enter fullscreen mode Exit fullscreen mode

e) Create a desktop entry for easy access:

echo "[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec="/opt/android-studio/bin/studio.sh" %f
Icon=/opt/android-studio/bin/studio.svg
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=android-studio" | sudo tee /usr/share/applications/android-studio.desktop
Enter fullscreen mode Exit fullscreen mode

f) Make the desktop entry executable:

sudo chmod +x /usr/share/applications/android-studio.desktop
Enter fullscreen mode Exit fullscreen mode

g) Launch Android Studio:

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

2. Installing Java Development Kit (JDK)

JDK is a crucial component for Android development. Here's how to install it:

a) Update package lists:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

b) Install default JDK:

sudo apt install default-jdk
Enter fullscreen mode Exit fullscreen mode

c) Verify the installation:

java -version
javac -version
Enter fullscreen mode Exit fullscreen mode

3. Setting Environment Variables

Setting ANDROID_HOME and JAVA_HOME is important for smooth Android development:

a) Find your Java installation path:

update-alternatives --display java
Enter fullscreen mode Exit fullscreen mode

b) Edit your .bashrc file:

nano ~/.bashrc  # with nano
code ~/.bashrc  # with vs code
Enter fullscreen mode Exit fullscreen mode

c) Add these lines at the end of the file:

export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 # Check for installed version
export PATH=$PATH:$JAVA_HOME/bin
export ANDROID_HOME=/opt/android-studio/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Enter fullscreen mode Exit fullscreen mode

d) Save and close the file.

e) Apply the changes:

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

f) Verify the settings:

echo $JAVA_HOME
echo $ANDROID_HOME
Enter fullscreen mode Exit fullscreen mode

With these steps completed, you'll have a fully functional Android development environment on your Linux system. Remember to keep your tools updated and explore the vast world of Android app development!

Top comments (0)