Step-by-Step Getting Started with Android Studio on Ubuntu

Published:7 July 2022 - 8 min. read

Nicholas Xuan Nguyen Image

Nicholas Xuan Nguyen

Read more tutorials by Nicholas Xuan Nguyen!

Have you been fascinated by the apps you see on your Android phone? Why not create one yourself? Android Studio on your Ubuntu machine is just what you need.

Android Studio is the official Integrated Development Environment (IDE) for developing Android apps by Google. Building a mobile app on a local computer may sound complicated. But don’t worry. In this tutorial, you’ll learn how to get started with Android Studio.

Sounds interesting? Dive in and build your own Android apps in no time!

Prerequisites

This tutorial will be a hands-on demonstration. If you’d like to follow along, be sure you have A Linux Ubuntu system – This tutorial uses Ubuntu 20.04.

Installing Java JDK

Android Studio delivers blazing-fast tools so you can build apps on every type of Android device. But before jumpstarting your journey with Android Studio, you first have to install Java Development Kit (JDK) since Android Studio is written in Java.

To install the OpenJDK version of the JDK:

1. Open your terminal and run the apt update command below to update your system’s package index.

apt update -y
Updating the System’s Package Index
Updating the System’s Package Index

2. Next, run the following apt install command to install the OpenJDK package (openjdk-11-jdk).

apt install openjdk-11-jdk -y
Installing the OpenJDK Package
Installing the OpenJDK Package

3. Finally, run the below java command to check the Java version installed on your machine.

java --version

Below, the version installed is 11.0.15, but yours might differ depending on the JDK release.

Checking Java Version Installed
Checking Java Version Installed

Install Android Studio from the Official Repository

After installing Java, you’re one step closer to mastering Android Studio. But of course, you still have to install Android Studio on your machine. You can install Android Studio, either from the official repository or via the snap tool.

But it’s always a good idea to install software from official repositories whenever possible, so you’ll receive updates automatically when they become available.

To add the Android Studio repository:

1. Run the add-apt-repository command below to add Android Studio’s official repository to your system.

The ppa flag indicates the repository is a Personal Package Archive (PPA), a way for individual developers to distribute software directly to users.

add-apt-repository ppa:maarten-fonville/android-studio

When prompted, press Enter to confirm adding the repository, as shown below.

Adding Android Studio’s Repository to the System
Adding Android Studio’s Repository to the System

2. After adding the repository, run the following command to update the local package index to include the contents of the new repositories.

apt update -y
Updating the Local Package Index to Include the Contents of the New Repositories
Updating the Local Package Index to Include the Contents of the New Repositories

3. Lastly, run the apt-cache command below to verify that the android-studio repository has been added successfully.

apt-cache policy
Verifying the Android Studio’s Repository is Added
Verifying the Android Studio’s Repository is Added

4. Now, run the below command to install android-studio and all the necessary dependencies via the official repository.

apt install android-studio -y
Installing Android Studio on Ubuntu
Installing Android Studio on Ubuntu

Installing Android Studio Using the Snap Tool

If you’re not a fan of adding a PPA to your source list, you can install Android Studio using the snap package instead.

Android Studio’s snap package indeed contains an application and all its dependencies. But remember, your Android Studio version might be slightly outdated as the snap package is usually a few releases behind the PPA. Choose wisely!

To install Android Studio using the Snap tool:

1. Run the apt install command below to install snap on your system if you don’t have snap installed on your system yet.

apt install snapd -y
Install Snap on the System
Install Snap on the System

2. Next, run the snap refresh command below to update the list of available snap packages.

snap refresh
Updating List of Available Snap Packages
Updating List of Available Snap Packages

3. Run the following command to install android-studio on your machine. This command pulls all the dependencies required to run Android Studio.

snap install android-studio

You might get a restriction error, as shown below. This error suggests that Android Studio can make changes to the system that could put your system at risk. This issue is common with snaps that are not confined to the security sandbox.

Getting a Restriction Error
Getting a Restriction Error

4. If you trust the Android Studio snap, run the following command instead to install Android Studio. The –classic flag allows snap to perform any system changes required as a traditional package.

snap install android-studio --classic
Installing Android Studio Using the Snap Tool
Installing Android Studio Using the Snap Tool

Starting Android Studio for the First Time

Now that you have Android Studio installed on your machine, it’s time to launch Android Studio and set it up for the first time. Setting up Android Studio is similar to setting up other software on Ubuntu.

1. Search for Android Studio in the Dash or Applications menu, and click on the Android Studio icon to launch it.

Launching Android Studio
Launching Android Studio

2. Select the Do not import settings option on the initial window, and click OK since it’s your first time setting up Android Studio on your Ubuntu system. The other option is for when you are upgrading from a previous version of Android Studio.

Choosing not to Import Settings
Choosing not to Import Settings

You can see below that Android Studio searches for available SDKs and configures itself for first use.

Viewing Android Studio Configures Itself for First Use
Viewing Android Studio Configures Itself for First Use

3. On the Welcome page, select Don’t send if you prefer not to send feedback at this time. Or choose the Send usage statistics to Google option otherwise, and click Next.

As new features become available in preview versions of Android Studio, you’ll be asked to send feedback about those features directly to Google.

Opting Out from Sending Feedback
Opting Out from Sending Feedback

You can turn the Data Sharing feature later off or on by going to Settings —> Appearance & Behavior —> System Settings —> Data Sharing.

4. Now, select the Standard installation option to use recommended settings for most users, and click Next.

Selecting Standard Installation
Selecting Standard Installation

5. Select your preferred UI theme, and click Next.

Darcula or Light? Dark themes have been popular these days, but the choice is entirely up to you.

Select a UI Theme
Select a UI ThemeSelect a UI Theme

6. Verify your settings, and click Next.

You can click on Previous if you need to change any settings.

Verify your settings and click Next.
Verify your settings and click Next.

7. Choose the Accept option to accept the license agreement terms, and click Finish.

Accepting the License Agreement
Accepting the License Agreement

As you can see below, Android Studio starts downloading and installing the required components, which may take a few minutes to complete.

Downloading Required Components
Downloading Required Components

8. Finally, click Finish to finalize the installation process.

Finalizing the Installation Process
Finalizing the Installation Process

After setting up Android Studio, you’ll see a welcome screen with a few options to get you started, as shown below.

Viewing the Welcome Screen
Viewing the Welcome Screen

Creating Your First Android Project

Now that Android Studio is running, it’s time to create your first Android project. Android Studio supports all programming languages of IntelliJ (and CLion), like JavaC++, and Go.

But for a start, you’ll create a project with a default template:

1. Click on New Project on the welcome screen to start a new Android Studio project.

Starting a New Project
Starting a New Project

2. Under Templates, select Empty Activity under Phone and Tablet, and click Next. This template is empty since your focus is on “getting started” with Android Studio.

Selecting an Empty Template for a Project
Selecting an Empty Template for a Project

3. Configure the project template with the following:

  • Name – Give your application a descriptive name. But for this tutorial, the project name is My First Application.
  • Save location – Use the default location or choose a different location to save your project.
  • Language – Choose the language you want to use for your project (Java).
  • Minimum SDK level – Choose the minimum API level your app will support. The lower the API level, the more devices your app can run on. The lowest API level is 16, which covers around 95% of all Android devices at this moment of writing.
  • Click Finish to create your project.
Configuring the Project
Configuring the Project

After creating your project, Android Studio takes time to sync the project sources. Once synced, you’ll see the following main files generated automatically on the left panel:

  • The app —> manifests —> AndroidManifest.xml file contains all metadata about your app, such as package name, app name, version, etc.
Viewing the AndroidManifest.xml File
Viewing the AndroidManifest.xml File
  • The app —> java —> MainActivity.xml file contains your app’s main activity.
Viewing MainActivity.xml File
Viewing MainActivity.xml File
  • The app —> res —> values > strings.xml file contains all string constants used in your app. You can edit these values to change the text displayed in your app.
Viewing the strings.xml File
Viewing the strings.xml File

4. Now, enable USB debugging and Install via USB on your Android device.

Enabling USB Debugging
Enabling USB Debugging

5. Connect your phone to your computer via a USB cable, and choose Transfer file / Android Auto, as shown below.

Choosing USB Connection
Choosing USB Connection

6. Tap on ALLOW on your phone if you get the prompt shown to accept your machine’s RSA key fingerprint.

Accepting RSA Key Fingerprint
Accepting RSA Key Fingerprint

7. Next, press Shift+F10 while on the Android Studio to run your application.

Running the Application
Running the Application

If the run is successful, you’ll see a Launch succeeded message (bottom-left). Your application automatically gets installed on your phone but takes some time.

Application
Application

8. Finally, look for your application on your phone and launch it.

Launching the Application
Launching the Application

Congratulations! Your first Android app is now running on your phone, as shown below.

Testing the Android Application on Mobile Phone
Testing the Android Application on Mobile Phone

Conclusion

In this tutorial, you’ve gone through getting started with Android Studio, from installing the software on your Ubuntu machine to creating your first Android app. Even though you’ve created your app with an empty template, don’t limit yourself, and try other templates.

At this point, you already have a working development environment and your first Android app. Why not add features to your app? Or perhaps start developing a new app and publish it on the Google Play Store?

Hate ads? Want to support the writer? Get many of our tutorials packaged as an ATA Guidebook.

Explore ATA Guidebooks

Looks like you're offline!