KVM, speed up the Android Studio emulator in Ubuntu

kvm speed up android studio emulator

Today's article is a tip for users who use Android Studio to develop their APPs. The only problem with this fantastic program is that you can despair when launching the emulator that it provides to test the application on duty. If your team is not an exceptional one, this may make you decide on another program to develop your applications. It takes a long time to execute (and when it does, its fluency leaves a lot to be desired).

Anyone who programs for Android on a regular basis is almost certainly using the android emulator that provides us Android Studio, although you have other options for it. For all those who are desperate with the performance of the emulator and also use Linux (Ubuntu in my case), here we are going to see a very simple solution by installing KVM (Kernel-based Virtual Machine). With it your team will not become a formula 1, but you will notice the difference.

The only requirement to be able to speed up the emulator is that you must have an Intel processor in the computer. In turn it must be compatible with Intel VT. For those who do not know, Intel VT is a virtualization technology that will allow us to significantly improve the performance of our virtual machines.

How to know if we can use KVM

Before you start to install anything, you better make sure it is feasible to use KVM in our team. For this, the first thing we have to know is whether our processor supports hardware virtualization. To do this, we are going to open a terminal and write the following command in it:

egrep -c "(vmx|svm)" /proc/cpuinfo

After writing the previous command, the terminal will return a numeric value. If the value shown is 0 it will mean that our CPU does not support virtualization. If the value is greater than 0, we will continue with the next step. This will be install CPU Checker from the terminal using the command below:

sudo apt intall cpu-checker

After the installation is finished, it is the moment in which we must find out if our CPU supports KVM. This is the system that we will use to speed up the emulator. To clear up doubts from the terminal, we are going to use this command:

kvm-ok

kwm ok

If we see something different like: "INFO: Your CPU supports KVM extensions INFO: / dev / kvm exists KVM acceleration can be used" we can continue on. In case the message shown is different, it means that we have to activate the Intel VT technology in the BIOS.

Installing KVM to speed up Android emulator

At this point, we are going to install a few packages necessary for accelerating the Android Studio emulator on our system. We will only have to write the following command string in the terminal:

sudo apt install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

In some cases, it will not ask us for configuration of any kind. But I have found others in which in the Postfix Configuration section you must select No configuration. This will prevent conflicts from starting to appear that can make our day bitter. To finish we just have to add our user to the following groups.

sudo adduser <tu usuario> kvm && sudo adduser <tu usuario> libvirtd

For the changes to the groups to take effect, you will have to log out of your account and log back in. Only members of the aforementioned groups will be able to use this technology for virtual machines. The previous step is essential to carry it out.

When we log in again we will verify the installation with the following command:

sudo virsh -c qemu:///system list

If everything has been correct, the terminal will return something like what you can see below:

correct kvm installation

In case of obtaining another result, it will be necessary to start over. We must perform the entire installation process again and re-add the users to the indicated groups.

In case we like more a graphical interface for KVM we can follow the instructions that a colleague left some time ago in the following post.

Without many complications and with a couple of commands we will have a more fluid and optimized emulator. Now we can continue programming and working without fear of "dying" when starting the Android Studio emulator.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Michael Gutierrez said

    Ubunlog,I use Genymotion. I need an Android on my PC and it is the only one that has worked for me. Does KWM work for other emulators that are not provided by Android studio?

    1.    Damian Amoedo said

      I know that with Eclipse it works too. But if you want more information, see the kvm documentation. Greetings.

  2.   Fjmurillov Murillo said

    excellent>

  3.   juanlettuce said

    Friends, for those who are doing this with version 1804 of ubuntu now the libvirtd group is called libvirt

  4.   buffoon said

    but what a piece of explanation, thank you very much teacher