Android x86 on QEMU
So You Like Android Games
The Android marketplace for games has become very broad over the course of the 12 years of existence of the OS. As mobile phone and tablet hardware has gotten better, higher quality games have been released to the Play store. Some notable titles being the Asphalt series, Nintendo offerings like Mario Run, Minecraft: Pocket Edition, Among Us, Fortnite, and countless thousands of indie games. This has been the impetus for many to find ways to enjoy these games without some of the drawbacks of gaming on mobile hardware. The desire for a quality gaming experience with mobile titles has led to the proliferation of Android emulators. The most popular of these is Bluestacks, which is highly focused specifically for playing Android titles and has features commensurate to its goal, such as key macros and multiple instances for games. Unfortunately, it has two major flaws: it is proprietary and it only works on Windows and MacOS. For people on UNIX-like OSs, there is luckily another way.
Android-x86
Soon after its inception, an unofficial Android port designed to run on processors with the x86 instruction set (mainly Intel and AMD processors) rather than ARM processors. It therefore uses modified versions of certain low level software components, such the kernel, graphics (uses mesa and drm_gralloc), installer, audio, filesystem, and more.
Setup
Android-x86 can be installed on bare metal or on a number of hypervisors. QEMU in conjunction with the KVM kernel modules is arguably the most performant method, so I’ll be using that. Install the QEMU package in your package manager. After having done so, we need to ensure that both the kernel supports KVM (it should be enabled by default nearly all linux distros) and that both requisite modules are loaded. Use zgrep to read the kernel config options:
zgrep CONFIG_KVM /proc/config.gz
CONFIG_KVM, CONFIG_KVM_INTEL, and CONFIG_KVM_AMD should all be enabled as modules (m flag). Now check that the modules are loaded:
My system is intel based, but you’d want kvm_amd on an AMD system rather than kvm_intel. If there is still an issue, make sure virtualization extensions are enabled in the bios settings as they’re often disabled by default. The next step is to install virglrenderer and sdl2 from your package manager as well.
To create the virtual machine, we initialize an image with the following command:
qemu-img create -f qcow2 android-x86.qcow2 64G
I will note the other option is raw over qcow as it will yield better storage performance at the cost of extra space. Now we create a shell script that contains the preferences we want for the virtual machine:
Change the number after smp to the number of cores you want the VM to have as well as the paths to the storage file and disk image. Make sure the shell
script is executable by running chmod +x android-x86.sh
or whatever you named the shell script.
Installation
Now run the shell script. The installation program is a series of ncurses prompts that will take you through partitioning and laying down the system files. It’s trivial enough. First, we create an MBR partition table and partition as follows:
Select the partition for installation:
Choose the extended 4 filesystem:
Say yes to installing GRUB. I answered no to making /system read-write, which will be fine for most people. After that, the installer will lay down all the system files. Then, we reboot:
Post Installation
Go through the system setup process. First, click on “See all Wi-Fi networks”
Then, click on VirtWifi and it should connect without issue. Skip “Copy apps & data”, unless you have a need. Connect to your Google Account (you’re going to need one for any paid games):
Configure the Date/Time settings:
I personally deselect all the options that are opted-in by default for Google Services. For maximum security, best to use a password over the other options like pattern and pin. I skipped the rest of the prompts as they were unneeded. After all that, you can choose the interface you want and now you’re left with a stock, rooted Android installation:
Ancillary Changes
Go into Settings > Android-x86 options and toggle “Enable Native Bridge” on:
Android-x86 doesn’t output in a high resolution by default. Launch the terminal emulator and run the following commands:
su
mount /dev/block/vda1 /mnt
vi /mnt/grub/menu.lst
Then, append video=1920x1080
or whatever resolution you’d like as shown below:
Then, reboot for the change to take place.
Happy Gaming!
Keep in mind that not all games will launch on Android-x86 as vanilla Android is intended to be used only on ARM platforms. However, plenty of games work great. Contact the developers of the app in question if it doesn’t run to get compatibility fixed.