How to Develop an Android App in Ubuntu

Android continues to dominate the mobile operating system market. With 71.93% of mobile devices running Android, the demand for apps that run on this platform continues to grow exponentially. There are various platforms and tools you can leverage to build Android applications. However, Android Studio, the official Android development environment, remains a popular choice amongst mobile developers. It runs on multiple platforms, including Windows, macOS, Linux, and ChromeOS.

Ubuntu is a successful Linux distribution with millions of PCs, laptops, and servers running this operating system (OS). As a desktop OS, it has everything a user needs to work online. It is free to use, and as it is built on Linux, it offers multiple development tools and libraries. Adding software to Ubuntu is simple using the Advanced Package Tool (APT) or Snap package manager. However, the standard Ubuntu images released by Canonical, who maintain this distribution, typically have most of the tools and apps you need.

Developing an Android App on Ubuntu

Android Studio provides developers with everything they need to build apps for the Android operating system. It includes development tools such as emulators and intelligent code editors that support the complete ecosystem from client to server. As Android Studio runs perfectly on Ubuntu, you can leverage the features of both platforms to create an integrated solution. As most web servers run Ubuntu, using this technology combination gives programmers several benefits.

Firstly, the code running on their local machine is identical to the code running on the production server that will eventually host the app’s backend. In addition to that benefit, installing all the relevant languages and libraries needed for Android is straightforward using APT and Snap. Ubuntu also supports all the popular programming languages required for Android development. Java, Kotlin, Python, and C++ are one-line APT command installs if they do not already come pre-installed with the Ubuntu operating system.

Setting up an Android Development Environment on Ubuntu

Getting your Ubuntu environment ready to develop Android apps requires a few installs and modifications. You need to install Android Studio, configure it, and set up your emulator. A core component in installing Android Studio is the Snap package manager.

The Snap Package Manager

As mentioned, you can install software on Ubuntu using APT. However, you can also use the Snap package manager. Both Snap and APT are centralized repositories users can leverage to install software on their Ubuntu system. The primary difference between these two application delivery mechanisms is the level of control.

As Ubuntu derives its kernel and codebase from the Debian Linux distribution, APT, a core component of Debian, has been the core package repository since Ubuntu’s launch in October 2004. Canonical, the creators of Ubuntu, created and launched the Snap package manager. A snap is a software bundle that incorporates the app and all its dependencies. The creators of Snap designed it to work without modification across many different Linux distributions.

The difference between APT and Snap is that APT primarily acquires packages from the distribution’s official repository. On the other hand, Snap gives developers the ability to package and deliver their apps direct to users with all the relevant dependencies via the Snap store. One of Snap’s key benefits is that it provides auto-update packages that ensure users always have the latest version.

Installing Android Studio on Ubuntu

Android Studio leverages the Snap package manager. You can install it via the terminal using this command:

snap install android-studio --classic

If you do not add the “ — classic” switch, later Ubuntu versions will throw an error, as shown in the screen clipping below.

After you run the command, the Snap package manager will download Android Studio and install it.

If you do not want to use the terminal, you can install Android Studio directly from the online Snap store by visiting this link —

Configuring Android Studio

The first time you run Android Studio, it will prompt you to import settings from previous installations. Since this example is a new install on a fresh Ubuntu instance, I select “Do not import settings”.

Android Studio uses a configuration wizard to help you set up all the relevant elements for your environment. You can opt for a standard installation or customize the features you require. The standard configuration installs the most common settings and options.

Once you have worked through all the steps, including selecting a dark or light theme and reviewing the files that Android Studio will install, you can click on finish to commence the configuration process. If your system can run the Android emulator in an accelerated performance mode, the configuration wizard will inform you, as shown below.

Configuring Hardware Acceleration for the Emulator

If your system is capable of running the Android emulator in an accelerated performance mode, you can run the following set of commands on a terminal to configure it.

sudo apt install -y qemu-kvm

Once the APT package is downloaded, run the following command.

sudo kvm-ok

If everything is in order, the terminal will print the following message.

INFO: /dev/kvm exists

KVM acceleration can be used

Creating an Android App on Ubuntu with Android Studio

When you start Android Studio, click on “+Create New Project.”

You can then choose from a range of project templates, as shown below.

Once you have selected your project, you will then need to configure the specifications for your app. As shown below, you can provide a name, a package name, the save location, the programming language, and the minimum SDK.

Android Studio will then download and configure Gradle in the background.

Once Gradle has completed its installation and configuration, you can then start developing your Android app on Ubuntu.

Hire the best android developers worldwide — vetted by Upstack, perfect for you!

Originally published at on April 29, 2021, by Chris Lazari.

The World's Best Developers on Demand