(OK) Running Android in a VirtualBox VM
https://www.ricston.com/blog/running-android-virtualbox-vm/
The first question that may come to mind after reading this blog post’s title is: “Why would I want to run Android in a VM when I have the emulator?”. For me it boils down to two main reasons:
- Android runs significantly faster in a VM compared to the emulator.
- VirtualBox offers support for devices such as Bluetooth whereas the emulator doesn’t. This means you can test Android Bluetooth applications in a VM.
There are two ways to make Android run on a VirtualBox VM. The first approach is well known: download the Android x86 fork and follow instructions from the fork’s project website to create a bootable ISO file. From there on, it’s easy to install Android on a VM. The drawback to this approach is that you won’t have the latest Android code. Additionally, changes you make to the fork must be merged with the AOSP (Android Open Source Project) for them to be included in future releases of Android.
The second approach gives you direct access to the latest Android code. However, it’s barely documented due to the fact that previously you couldn’t build ‘out of the box’ an Android VDI (Virtual Disk Image) with the AOSP. To build the Android VDI and install it in your VM, follow these steps:
- Get the
Android source code from the AOSP site and follow the online instructions to setup the environment.
- When you are ready to build the project, execute the following command to set the environment variables for Make: “lunch vbox_x86-eng”.
- Run “make installer_vdi” to build the project. Make will build the project and produce a VDI named “installer.vdi” located in “out/target/product/vbox_x86”. This VDI contains Android plus its installer.
- Create a Linux VM and add the “installer.vdi” as an extra HD to the VM.
- Start the VM and press “F12” during bootup.
- Select the HD which represents the “installer.vdi”.
- Choose the first option, that is, “Android Install to /dev/sda from /dev/sdb”.
- When installation is complete, enter the command “reboot”. After that, you should be able to launch Android from your VM.
One small note, I had several problems trying to compile Android for VirtualBox from my Mac OS X. So probably the best solution is to build Android from Linux.