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

ARM-C said…
When I follow your directions, I cannot get the .vdi to boot. It starts all fine, then I get messages that it is unable to locate files and essentially freezes during boot.

Message reads:
[1.636003] init: cannot find '/system/bin/servicemanager', disabling 'servicemanager'

A slew of other messages similar appear.

Any suggestions?
David Young said…
Hi ARM-C,

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!
Cyberponcho said…
Hi David, thanks for this post, i downloaded the .vdi file, set up a virtual machine as you said but when it boot then comes a kernel panic and the following message 'Spurious ACK on isa0060/serio0. Some program might be trying access hardware directly' do you know any way to get past this problem? Thanks in advance :-)
David Young said…
Hi Cyperponcho,

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.
Little mouse said…
Hello David, thank you for your publication.
Do you know how I can create a virtual SD card ?
David Young said…
I haven't tried creating an SD card for this particular virtual machine, but in the past I partitioned it according to these steps (scroll to about midway down the page). Those steps were actually done while installing from the Android-x86 iso so may not apply here, but it might be possible to attach another virtual hard drive and partition it from this VM or another Android-x86 copy.

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!
Little mouse said…
Thank you very much for your reply Daniel M Young, But I have another problem with this version ... actually it is possible to connect to wifi but it doesn't seem possible to detect and get an idea of ​​wireless access points located by the system ... What do you think about this? thank you
David Young said…
I haven't actually tried it with wifi either, but I usually have it running within VB on a host already connected by wifi and then access the network through NAT. Do you need to connect to wireless access points from the virtual machine directly?
Little Mouse said…
Yes Mr David,

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!
David Young said…
No problem...let me know if you figure it out!

Popular Posts