Getting started with Android Studio on Ubuntu

A Quick tutorial on setting up Android Studio on Ubuntu for Native App Development

I had never developed Android apps before. In fact, I have never been too keen on writing Java code, which is why I didn't have the necessary skills to develop Andriod apps using Java. Honestly, I have barely even learnt any JavaScript now, enough to just dabble my ways around the web. Knowing some ReactJS, I thought this could be an opportunity to develop some native mobile applications using ReactNative, and for that I needed to install Android Studio on Ubuntu (I used 20.04).

If you too are looking to create native mobile apps for Android without knowing Java using some framework like ReactNative, this brief tutorial might help you setup Android Studio on your computer running Ubuntu to get you up to speed with your actual application development.

Installation

The first thing that you need to do is download the From the Official Android Developers page, download the latest .tar.gz file on your system

  • Installing is as simple as unpacking the binaries of the zipped file, and storing it in an appropriate location for your applications, such as within **/usr/local/** for your user profile, or **/opt/** for shared users.
  • If you're using a 64-bit version of Linux, you need to install some 32-bit libraries with the following command:
    sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
    
  • Now, to launch Android Studio, open a terminal, navigate to the **android-studio/bin/** directory, and simply execute:
    ./studio.sh
    
  • Once launched, select whether you want to import previous Android Studio settings or not, then click OK.

The Android Studio Setup Wizard guides you through the rest of the setup, which includes downloading Android SDK components that are required for development.

Configure VM acceleration on Linux

The Android Emulator can use hardware acceleration features to improve performance. Linux-based systems support VM acceleration through the KVM software package.

Running KVM requires specific user permissions. Make sure that you have sufficient permissions as specified in the KVM installation instructions. To use VM acceleration on Linux, your computer must also meet these requirements:

NOTE: For Intel processors, support for Virtualization Technology (VT-x), Intel EM64T (Intel 64) features, and Execute Disable (XD) Bit functionality is enabled. For AMD processors, Support for AMD Virtualization (AMD-V) is available

Check whether KVM is currently installed on Linux

  • Check whether KVM is currently installed on Linux using the cpu-checker package containing the kvm-ok command. First, install the package.
    sudo apt-get install cpu-checker
    egrep -c '(vmx|svm)' /proc/cpuinfo
    
    An output of 1 or greater means that virtualization is supported. An output of 0 means that your CPU doesn't support hardware virtualization.
  • Run the kvm-ok command:
    kvm-ok
    
    Expected output:
    INFO: /dev/kvm exists KVM acceleration can be used
    

If you get the following error, it means that you can still run virtual machines. Your virtual machine will be slower without the KVM extensions.

INFO: Your CPU does not support KVM extensions, KVM acceleration can NOT be used.

Install KVM on Linux

If KVM acceration can be used, use the following command to install KVM (Cosmic 18.10 or later):

sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils

Now you can use VM acceleration for running your Android emulator. Finally, to launch Android studio, navigate to the android-studio/bin/ directory, and execute

./studio.sh

That's it! If you have reached this point, you should have been able to successfully install and launch Android Studio on your Ubuntu 20.04 system. Now you are ready to begin your Android development on Ubuntu using some of the most popular native app development frameworks like ReactNative.

Stay tuned for the next part of this story to learn about just that! Until next time, Cheers 🍻