Installing and using Android Studio as virtual device on Ubuntu 16.04
I'm struggling to install and use Android Studio as a virtual device (AVD) with Ubuntu 16.04.
I tried using Ubuntu make:
umake android 'android-ndk'
but that didn't work, so I tried it the old fashioned way.
Now I'm having emulator troubles and can't really use a real device because it isn't working.
Can anyone provide a step by step installation for Android Studio and QEMU VM?
Solution 1:
Installing and using Android Studio on Ubuntu 16.04 is a task that needs a certain strategy and you need to follow certain steps.
Your system must be equipped with a 64-bit CPU capable of supporting Hardware Virtualization and at least 4 GB of RAM but this will not be enough if you're planning to use other programs while Android Studio is running. In that case, 8 GB is a must. You must be using the 64-bit Ubuntu 16.04 of course.
You need to install the Oracle JDK 8 and this can be done by adding the webupd8team java ppa to your system (
sudo add-apt-repository ppa:webupd8team/java
) and installing both oracle-java8-installer and oracle-java8-set-default.Install the complete KVM/qemu on your system by following the instructions given here.
In the beginning, you will find instructions on how to check if your system's processor is ok for use with KVM. Don't forget to log off and back on after the installation, otherwise your user will not be activated as a member of the libvirtd group and you will not be able to use KVM.Download the latest Android Studio .zip file from the Android Developer's site and make sure you install the 32-bit support files listed over there. NOTE: The file lib32bz2-1.0 does not exist on 16.04, so you have to install libbz2-1.0:i386 instead, using
sudo apt-get install libbz2-1.0:i386
.Extract the contents of the .zip file in a folder of your choice and create a launcher for the studio.sh file you will find in the android-studio/bin folder and if everything else is ok, it should run fine.
You will need to install all the necessary libraries and images using the android SDK and create the AVD's you'll be using of course but I think you must know that already since you are a developer. In order for the emulator to actually use KVM, you must start it using these emulator parameters:
/pathTo/emulator -avd avd_name -qemu -m 1024 -enable-kvm
Update: The command above has been deprecated. You can run your emulator with full hardware virtualization support now by simply using -accel on.
/pathTo/emulator -avd avd_name -accel on
This switch is not necessary though, since the default setting for -accel is auto which means that if KVM is installed correctly, it will be used by default.
The value of 1024 is an example. Use the same amount of memory you configured your AVD to use. Further instructions on how to insert the parameters above to android-studio instead of launching the emulator manually, you can find on the android developers site. Personally, I prefer to launch it manually and have it there whenever I need it.