Hello Level1Techs!
I’ve spent the last week or so exploring a way to run Android ARM apps on an x86-64 based computer, on Windows it looks like there are various popular Android emulators that you just download and use, but the problem is two/three-fold, you’re using a proprietary OS to use a proprietary emulator program to run (potentially) proprietary Android programs!
Thankfully with the power of Linux and various other FOSS projects, it is possible to roll your own Android emulation solution!
Now, to be fair, in my limited testing, I have not had much luck running ARM apps in this VM, your mileage may vary, but the ONE game I was interested in emulating actually does work well, I am reluctant to say which since I don’t trust the devs/company to not intentionally sabotage it.
I am running BlissOS 15 (FOSS edition!) inside a virtual machine managed by virt manager, using QEMU/KVM!
The specific release I used to spin up the VM is:
Bliss-v15.8.6-x86_64-OFFICIAL-foss-20230703.iso
I started with the automated install which uses GRUB, and I wanted to see if it would be possible to use rEFInd instead since I prefer it on UEFI based machines, so on a new install, instead of using the handy installer, I had to extract the kernel, initrd, and Android system image from the ISO, copy them to the manually partitioned disk that I would boot from, and set up rEFInd manually on the EFI system partition, complete with all the boot entries that were in the GRUB config. I even used an EFI shell for the first time in order to add rEFInd as a boot entry!
Just to make the boot screen look pretty, I applied the dark version of refind-theme-regular, and I used ImageMagick to convert this logo into a smaller icon for the boot manager to use.
Images
Overview
- Host: Pop!_OS 22.04
- Chipset: Q35
- Firmware: UEFI w/o secureboot
- Guest OS: BlissOS (Android-x86 9.0)
- Memory: 4GiB
- vCPUs: 4
- 3D acceletation: VirGL
- Storage: 16GiB
I granted superuser to the Android shell for adb, and this particular version of BlissOS seems to have libhoudini (sadly proprietary) in order to run ARM apps in this VM!
For adb/usermode networking, I don’t have a NIC setup in virt manager, instead I modified the xml to manually add qemu parameters for the NIC and port forwarding to allow adb connect localhost:4444 to work. I used to use virbr0 for this but now that I discovered this XML magic that eliminates the need for specifying an IP address I don’t see myself going back.
Credit goes to this question and this one for showing me that trick.
I set rEFInd boot screen to be 800x600 to make reading the options easier, it made the command line arguments invisible in the editor, BlissOS itself is in 720x1280 via kernel parameter since I believe that is the most common resolution for smartphones.
Games
-
Clash Royale: Won’t start, stuck on app icon.
-
Arknights: Game appears to start but this error does not allow me to advance.
-
Blue Archive (JP): Won’t start, stuck on black screen, had to spoof Pixel 7a in Aurora Store to download.
-
NIKKE: Seems to require “FFMPEG_CODEC=1” kernel parameter, I chose server & downloaded data but with some errors, graphical glitches, made it as far as the login screen where making a guest account errors out, had to spoof Pixel 7a in Aurora Store to download.
-
Honkai Star Rail: Game sometimes launches, sometimes errors out, didn’t really want to signup.
I’ve not tried other apps or anything microG/Google Service related since I have absolutely zero interest in that, I did disable microG since I do not want it.
Android apps that have been built for x86-64 are probably fine, AppManager from F-Droid is built for x86-64 and works just as I expected.
Miscellaneous
Screen rotation seems broken? If an app required switching orientation my cursor would stop working in the VM, had to reboot and specify a modified video paramater to boot in either landscape/portrait mode to avoid this.
I haven’t looked into VFIO to do stuff like pass through a real GPU, I imagine that could greatly improve performance and maybe compatibility? VirGL seems to be enough for my use case though.
Why not Waydroid/Anbox/etc? That was too complicated imo, setting up Waydroid seemed cumbersome, and I don’t know what extra work is needed to get ARM apps to run on that, besides that, I do tend to prefer virtualization anyway, I do want to try my hand at VFIO at some point .
Ideally I would like my VM to boot into GrapheneOS w/ libhoudini since I suspect it could offer better compatibility, but building it from source seemed daunting. I’d heard BlueStacks uses QEMU, don’t know if that’s true, but if so, if would be cool to use that instead of libhoudini.
Credit
My thanks go to the author of this article for giving me the idea and inspiration, his setup was close to what I wanted, but he setup the virtual machine on Windows! A Linux based solution was more to my liking.