(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:

  1. Android runs significantly faster in a VM compared to the emulator.
  2. 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:

  1. Get the Android source code from the AOSP site and follow the online instructions to setup the environment.


  2. When you are ready to build the project, execute the following command to set the environment variables for Make: “lunch vbox_x86-eng”.


  3. 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.


  4. Create a Linux VM and add the “installer.vdi” as an extra HD to the VM.


  5. Start the VM and press “F12” during bootup.


  6. Select the HD which represents the “installer.vdi”.


  7. Choose the first option, that is, “Android Install to /dev/sda from /dev/sdb”.


  8. 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.


posted @   张同光  阅读(160)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示