Android 4.0 (Ice Cream Sandwich) on Virtualbox
Yesterday to my utter delight I realized that the Ice Cream Sandwich version of Android (4.0) can run in Virtualbox. I've been contemplating programming an Android app for the tablet form factor but don't quite have the resources to purchase a spanking new ICS tablet, and a virtually free virtual machine fits the pocketbook much better.
For Android ports, I normally turned to the venerable Android-x86 project. Indeed, they have just released an ICS port designed for the AMD Brazos platform, but the build apparently does not support internet connectivity or use of a mouse, which of course makes use within a virtual machine on a laptop rather challenging. Fortunately, I found another blog posting that referenced a Japanese site whose developer has provided a .vdi virtual hard disk file for loading directly within Virtualbox. Best of all, this not only includes mouse support and networking, but also hooks up with ADB for Android app development.
To set up the Virtualbox environment, I followed these steps:
For Android ports, I normally turned to the venerable Android-x86 project. Indeed, they have just released an ICS port designed for the AMD Brazos platform, but the build apparently does not support internet connectivity or use of a mouse, which of course makes use within a virtual machine on a laptop rather challenging. Fortunately, I found another blog posting that referenced a Japanese site whose developer has provided a .vdi virtual hard disk file for loading directly within Virtualbox. Best of all, this not only includes mouse support and networking, but also hooks up with ADB for Android app development.
To set up the Virtualbox environment, I followed these steps:
- Download the pre-made .vdi file with Android 4.0.
- Create a new virtual machine with the following settings:
- OS Type Linux 2.6
- 512MB RAM
- Acceleration: VT-x/AMD-V (which is apparently required for ICS at least on this build), nested paging, and PAE/NX
- Bridged network adapter (but see below)
- 2GB hard drive (not required)
- Hard disk pointing to the .vdi file. Note that the disk will be attached by default to a SATA controller, but the disk should be removed from there and attached to the IDE Controller instead.
The virtual machine booted and worked out of the box! Next, I needed to connect the virtual machine to ADB so that I could load up my app for testing:
- Open a command-prompt in the directory of adb.exe (ie Shift-right-click in android-sdk-windows\platform-tools and choose the "Open command window here" item).
- Enter adb connect [ip-address]. This turns out to be the most difficult step because unlike using netcfg in the Android-x86 builds, I haven't found an easy way to determine the local IP address. One method is to log into your router and check the DHCP client list. The list usually shows IP addresses for the various MAC addresses of devices connected to the router. You can find the MAC address of your device by right-clicking on the networking icon in the Virtualbox status bar, choosing "Network adapters...", and then opening the "Advanced" section.
One of the challenges I've faced while on the road is the inability to connect while completely disconnected from the internet or any router. In this case, I need a way to make a solely local network connection from ADB to the virtual machine. Fortunately, this posting describes a simple method to make that connection:
- In the same network adapters page from within Virtualbox, change the "Attached to" selection to "NAT".
- Choose "Port forwarding", and in the "Host Port" and "Guest Port" sections, type "5555". If you have multiple virtual machines and want to connect to each of them, you could increment the host port for each of the forwarding rules while keeping the same guest port for each device (eg host port 5556, guest port 5555 on a second virtual machine).
- From the command-prompt in the directory of adb.exe, enter adb connect localhost.
The Android 4.0.1 device should pop up in the DDMS devices listing from within the Eclipse development environment, and packages should transfer to ICS with glee.
Comments
Message reads:
[1.636003] init: cannot find '/system/bin/servicemanager', disabling 'servicemanager'
A slew of other messages similar appear.
Any suggestions?
I realized that the ICSImage.vdi file actually needs to be attached to the IDE Controller rather than the default connection to SATA. I'll update that in the posting.
Thanks for pointing it out!
Hmmm, I haven't seen that error myself. I was trying to look it up, and some folk appear to have similar errors with other versions of Android using Android-x86 (http://code.google.com/p/android-x86/issues/detail?id=302) and thought it may have to do with support for hardware virtualization on different platforms. What kind of CPU do you have? I've only tested on Intel Core 2.
Do you know how I can create a virtual SD card ?
I found a newer ICS build from tabletsx86.org that can be installed more like a standard Android-x86 machine (see here), which includes a wizard for creating the SD card. These newer builds even have networking working out-of-the-box and all to boot!
I need to see the list of acces point from the virtual machine directly.
I try but i can't see the list in the virtual machine...
But i don't want to bother you, I will try with another method ;)
Thank you Sir!