Get Started with Android application development using Linux and Android SDK

Developers interested in the Android mobile operating system are able to use the Android SDK and various IDE software to code applications. These apps can then be made available and marketed to Android users around the world.

There are a lot of choices when it comes to programming Android applications. Your coding environment can involve a Linux system and a variety of different IDE programs to facilitate all of the software development. The trouble here is that each Linux distribution will often have a different set of requirements to run the sofware, and a separate list of steps that need to be followed.

In this guide, we’ll go through the step by step instructions to install Android Studio – which is one of the most popular Android IDEs – on a Linux system. This will work on any distribution because we’ll be using Snap package manager to manage the installation. Love it or hate it, the Snap package manager gets your system ready for Android development very quickly, by handling all the dependencies and working identically on any distribution you’re running, whether it be Ubuntu, Debian, Red Hat, CentOS, AlmaLinux, openSUSE, or any other type of Linux system.

Follow along with us below as we setup Snap package manager, install Android Studio, and then program a Hello World Android application to verify that everything is working properly.

In this tutorial you will learn:

  • How to setup Snap package manager
  • How to install Android Studio and SDK packages
  • How to create a Hello World test application
  • How to run an Android application on an emulated device

Developing and running an Android app on a Linux system

Developing and running an Android app on a Linux system

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software Snap, Android Studio
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install Snap package manager



It’s perfectly possible to install the Android SDK, Android Studio (or a different IDE), and the necessary prerequisites by using your system’s package manager or downloading the software on the web. However, the process for this can vary widely, and we want to make sure that you get up and running with a working Android development environment. Therefore, we recommend using Snap for the installation process, which will handle dependencies for us and run the software in a sandbox.

Newer versions of Ubuntu should already have Snap enabled, as Canonical developed the feature and first introduced it on their own distribution. It’s also available for most other Linux distributions, but must be installed first. If you’re not running Ubuntu, please see our guide on How to setup Snap package manager on any Linux distro to install Snap, then rejoin us here for installing Android Studio.

How to install and use Android Studio

Follow the steps below to install Android Studio, then use it to create your first Android application, a Hello World program that will verify we have a working coding environment.

  1. Once you have Snap enabled, open a terminal and use the following command to install the Android Studio snap.
    $ sudo snap install android-studio --classic
    
  2. After Android Studio is done installing, you can open it from your system’s application launcher.
  3. Open up the newly installed Android Studio

    Open up the newly installed Android Studio



  4. Since this is your first time opening Android Studio, you’ll need to go through some initial prompts that pop up. It’s just a setup wizard that will take you through a few things, and will also fetch some updates and other dependencies from the web. All of these prompts are easy to follow and self explanatory.
  5. Going through the Android Studio setup wizard

    Going through the Android Studio setup wizard

  6. Note that a hefty amount of software will be downloaded for the Android SDK and its related packages. This could take a little while on slow internet connections.
  7. Android Studio is downloading additional SDK packages

    Android Studio is downloading additional SDK packages

  8. Once the setup wizard wraps up, you can click on “Create New Project” to begin coding the Hello World application.
  9. Create a new project in Android Studio

    Create a new project in Android Studio



  10. For a simple test application like this, choosing an empty activity will be most appropriate.
  11. Select empty activity for our test app

    Select empty activity for our test app

  12. Fill out your application name, which we’ll just call “Hello World.” The other settings should be fine at their defaults. Normally, you would want to change the “minimum SDK” requirement, but for this first test application, it doesn’t matter much. Click on finish when you’re ready.
  13. Filling out the details for our Hello World application

    Filling out the details for our Hello World application

  14. Android Studio will now open your new project. This may take a minute as the background processes (viewable at the bottom of the Android Studio window) finish their job. After everything’s ready, you can click on the activity_main.xml tab to see how your Hello World application looks. Feel free to make any changes that you’d like. Notice that we don’t have to do any actual coding just for this test application – the hello world text has already been generated for us.


  15. Click on the activity_main.xml tab to see how the app will look on a phone screen and to edit certain details

    Click on the activity_main.xml tab to see how the app will look on a phone screen and to edit certain details

  16. When you’re ready to launch the program on an emulated device, click the green play button.
  17. Click the green play button to run the app on an emulated phone

    Click the green play button to run the app on an emulated phone

  18. As the emulated phone finishes powering up, your Hello World application should open automatically. This is just a basic application, but more complex apps would allow you to interact with it for more testing.
  19. Our Hello World application is successfully running on the emulated mobile phone

    Our Hello World application is successfully running on the emulated mobile phone

That’s all there is to it. If your Hello World application executed successfully, you can continue using Android Studio to code other Android applications.

Closing Thoughts

In this guide, we saw how to get started with developing Android applications on a Linux system by installing Android Studio and SDK. We also learned how to create a test application and run the app on an emulated mobile device for testing. This should be enough to get you started with Android app development on any Linux distro.



Comments and Discussions
Linux Forum