Here, here and here I’ve blogged about Android-x86 (Ice Cream Sandwich aka Android 4.0) running in Virtualbox or VMware player/workstation. Both virtualization programs may be used as device emulators for app testing. Now I like to demonstrate, how to mount SD card space in ice cream sandwich x86 and how to install apps or access android using android debug bridge.
Connecting Android Debug Bridge (adb) to Android VM
Accessing a running (virtual) android machine from Windows (or Linux), android debug bridge (adb) will be helpful. Android debug bridge is part of Android SDK and the file adb.exe will be found in folder android-sdk_r10\platform-tools. Also the 7z-archive provided from VMLite corporation  contains (beside a Virtualbox disk file with ice cream sandwich x86 and a SDcard.vdi file) also adb.exe.
- To invoke android debug bridge, navigate to the folder containing adb.exe using windows explorer.
- Press Shift key, right click the folder name und select context menu command Open Command Window Here.
- Then connect adb to Android VM using the command:adb connect <address> (ENTER)
The <address> used in the command above depends on the environment. If the Android VM is configured with a network bridging network adapter, the ip adress of the VM machine may be entered.
But how to obtain the VM’s ip address? This ip address may be obtained from the router’s configuration page. Below is the web page of my router showing two entries.
The command to connect android debug bridge to this Android VM will be: adb connect 192.168.178.22.
Note: I have used VMware workstation for my tests, because it was the virtualization solution available on my machine. You may also use Virtualbox or VMLite workstation. But there is one restriction: if you use Virtualbox portable, bridged networking isn’t supported.
If bridged network mode isn’t available, you can use NAT network mode and try the following command to connect:
adb connect localhost
If you can’t connect using adb to a VM using NAT as network adapter, try to execute the following command:
VBoxManage modifyvm Android-v4 –natpf1 adb,tcp,*,5555,*,5555
in command prompt windows – to define a tcp port forwarding from host to guest.
On my system I’m using Virtualbox portable. The command VBoxManage.exe isn’t useable (class not registered). I tried to invoke a dialog box “rules for port forwarding” from Virtualbox network configuation page. But (at first) I was not successful to define a port forwarding.
Update: The VBoxManage modifyvm command mentioned above caused an error “—natpf1 isn’t a valid command” on my 2nd machine with VMLite workstation – don’t know what went wrong.
At least I was successful to define a valid port forwarding rule in Virtualbox portable, using the GUI. Here are the steps: Right click the network icon in VM’s statusbar and select the network adapter command. On the network adapter configuration tab click the button Port forwarding and enter the host’s and guest’s port number 5555 into the dialog box window shown below. That’s all. After closing the dialog box you should be able to connect adb to a vm using the command:
adb connect localhost
adb connect localhost:5555
In my Virtualbox portable environment I received an “error: more than one device and emulator” notification. The command adb devices reported two devices “emulator-5554” and “localhost:5555”. Here I found a solution: I have to use modified adb commands to connect to the right device:
adb –s localhost:5555 shell
for instance, to access the VM.
Mount a SD card in VM
The ice cream sandwich images I’ve introduced here, here and here doesn’t come with support for a SD card. But VMLite corporation added a file sdcard.vdi to their Android-v4.7z image. After unpacking the .7z file, sdcard.vdi need to be associated as a 2nd virtual disk to the VM (below I used Virtualbox).
After booting Android 4.0, the SD card needs to be mounted manually (auto mount isn’t supported yet). After connecting adb successfully to your Android VM using the command shown above, you may execute the following commands.
mount -t vfat /dev/block/sdb /mnt/sdcard
The first line invokes the shell. The 2nd command uses the shell and mounts the SD card in directory /mnt/sdcard. The third command exits the shell.
If you get an error message when runing adb, you may try the following commands:
and mount the SD card as mentioned above. If are more than one device and emulator are reported, use switch –s and device name within adb shell command (see my update above).
Note: Although I have mounted the SD card, some apps can’t access this SD card store and delivers errors – see also .
Installing apps using adb
Android 4.0 x86 prepared for Virtualbox doesn’t come with too many apps. To experiment a little with ice cream sandwich or use Android VM as a fast device emulator, you in need to install apps. This can also be done using adb. The command:
adb install .\apk\notepad.apk
tries to install notepad.apk to Android VM. The .apk file is located in subfolder \apk on host system (Windows or Linux). Apps are installed under /data/local/tmp/…apk in Android.
Note: According to @volker_kempter , using the command: adb install .\apk\notepad.apk /sdcard should install on SD card. You can also use commands like:
adb -s localhost:5555 shell pm get-install-location
to query install destination (0 = automatic, 1 = internal, 2 = external). And the command:
adb -s localhost:5555 shell pm set-install-location 2
directs all installs to SD card, whilst a 1 within the command sets it back to internal store.
I was also able to install notepad.apk. On my system I have also installed two file managers (Astro file manager and File expert). Below is the APPS page of my Android VM shown. I have had installed also Google market, Terminal Emulator und WiFi File Explorer.
Note: App .apk files may be found for download using a search engine. Also self developed apps are installable. But I experienced, that not all apps are executeable. Terminal Emulator, Adobe PDF viewer oder Google Market stalls during launch. WiFi File Explorer won’t work due to a missing WiFi connection. Also WiFi File Explorer and some other apps as well switches the screen from landscape to portrait mode. According to a tip from @volker_kempter , screen rotation may be locked using Settings app, go to menu item Display and check out Outo-rtotate screen. Therefore you need to experiment and test a bit, which apps are executable.
Apps already installed via adb may be launched or uninstalled using Android tools. Below is the settings page with selected Apps entry.
You can select an entry with a right mouse click. Then a subpage with options to execute and uninstall that app will be shown.
Update: If you managed to connect adb to VM, it’s also possible to use Dalvik Debug Monitor from Android SDK (may be found in folder android-sdk_r10\tools). Just let the command prompt windows with the adb connection open and launch Dalvik Debug Monitor via ddms.bat in folder tools. Using the Device menu in Dalvik Debug Monitor allows access to File Explorer, show process status and more. But the command Screen capture will fail in most cases, because the x86 port uses some modifications. In most cases I received a “unable to get frame buffer: timeout” message. But screenshots from a VM will be no major pain on a Windows host.
That was in brief a few information about how to communicate with Android VM from host. Further information about adb commands may be found in [3,4].
a: Ice Cream Sandwich-Testdrive in Virtualbox – Part I
b: Test: Ice Cream Sandwich in Virtualbox – Part II
c: Android-x86 Ice Cream Sandwich from VMLite Part III
d: Running Ice Cream Sandwich in VMware Part IV
e: Experimenting with ICS (in Virtualbox, VMlite, VMware)
f: New Virtualbox Ice Cream Sandwich-Build