Experimenting with ICS (in Virtualbox, VMlite, VMware)

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.


Anzeige

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 [1] contains (beside a Virtualbox disk file with ice cream sandwich x86 and a SDcard.vdi file) also adb.exe.

  1. To invoke android debug bridge, navigate to the folder containing adb.exe using windows explorer.
  2. Press Shift key, right click the folder name und select context menu command Open Command Window Here.
  3. 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.


Anzeige

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

adb shell
mount -t vfat /dev/block/sdb /mnt/sdcard
exit

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.

ADB Shell: Formatting a SD card

If you get an error message when runing adb, you may try the following commands:

adb kill-server
adb shell

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 [4].

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 [4], 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 [4], 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].

Links:
1: Download Android-v4.7z (VMLite)
2: ADB commands (German)
3: ADB commands (cyanogenmod wiki english)
4: Discussion in VMLite forum

Similar arcticles:
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


Anzeige

Dieser Beitrag wurde unter Allgemein abgelegt und mit , , , , , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

14 Antworten zu Experimenting with ICS (in Virtualbox, VMlite, VMware)

  1. Crístian Viana sagt:

    have you tried it with QEmu/KVM?

    • Günter Born sagt:

      @Chis: Thx for commenting. I haven't tried KVM, because I use Windows hosts on my machines (Linux runs only as guests in VMs).

      Quemu is included as emulator in Android SDK – but the emulator is terrible slow (it will emulate ARM code by default). Therefor I have searched for solutions, to overcome that bottleneck.

      BTW: the current Android 4.0.1 build from VMLite corporation comes with automount for SD cards and also with guest integration (mouse support and shared folders).

  2. Günter Born sagt:

    [Update: VMLite corporation has uploaded a new .vdi image file that contains now mouse integration and shared folders (see http://bit.ly/tB3dtO).

    I have posted my findings about that build ICS 4.0.1 in VMLite forum as well (http://bit.ly/sZTJmu):
    – currently managed space in data\tmp folder is running low
    – not possible to install an .apk file.
    – Also installing on automounted SD card seems not possible.

    I will report, if a more suitable update is available.

  3. exa sagt:

    "VBoxManage modifyvm "Android 4" –natpf1 adb,tcp,*,5555,*,5555"

    Works, add two – in front of natpf1 instead of one

    • Günter Born sagt:

      @exa: thx for your comment – I've tried both, one – and two — in front of natpf1, both failed.

      BTW: The command in my blog article contains two – -, but WordPress & the browser seems to render it into one dash (you will see that, if you copy & paste the command into an editor window or in command prompt window).

  4. MrFX sagt:

    Hi, i've tested the ICS with virtualbox on a Mac, works so far, installed Market too, but if i input my details for the google account, it shows up a message after a minute or so: no network connection… Browser and Mail works!

    Any hints?

    • Günter Born sagt:

      @MrFX: It seems that the VMLite VBox-Image contains some issues preventing serveral things. I have two suggestions.

      a) Try to download a new image form http://www.vmlite.com
      b) Try the .iso builds I've mentioned here

      The iso builds mentioned in b) needs a WiFi connection – maybe it will be a bit difficult to manage that (I failed at least and wasn't able to bring eth0 up). Therefore I'm using now to approaches:

      i) I use some of my netbooks to run Ice Cream Sandwich native (either as a life system from a USB stick – or as an installed version from a SD card)
      ii) run it in Virtualbox/VMware workstation using the VMLite image – in this environment I'm using adb to install .apk files for test purposes

      But ii) isn't the right approach for someone that intends to "use" Android as a guest on a native Windows or Mac OS X machine. Maybe VMLite will manage it in a few days to create a VBox image that includes android market. Have a closer look at this thread.

      HTH

      Günter Born

  5. Lars Vogel sagt:

    Thanks Günther for pointing to this blog entry in Google+. I was a bit behind with reading it, but this really looks useful.

    Thanks again, Lars

  6. Gaurav sagt:

    Hello, Can you please point out how you managed to install android market? Does it require google services framework also?

    thanks!

  7. Günter Born sagt:

    @Gaurav: Hu, you are right, I wrote above "I installed Google market". But it's a few days, since I wrote the article. So I don't remember exactly, how to set up market (especially, because newer builds for android-x86.org comes with market).

    Knowing my own basic skills, I assume, that I simply searched the web for a google market .apk and installed it by tapping the .apk from a file manager. No additional frameworks was necessary.

    Perhaps try the apk from [1] – otherwise I would suggest, to contact the forum of the image creator (VMLite forum oder android-x86.org).

    Hope that helps – and sorry, that I don't remember exactly, what I did in december 2011.

    1: http://www.androidpolice.com/2011/11/01/download-android-market-3-3-11-adds-new-settings-default-auto-update-update-over-wi-fi-only-shortcuts-and-more/

  8. minh sagt:

    Can i add or install android market into this Android 4.?if i can, can you show me how to do.tkz a lot!

    • Günter Born sagt:

      @minh: I'm not sure, whether Google Play (the new name for Android market) is installable on this old ICS builds. I haven't used these builds since weeks, because the current RC1-builds from android-x86.org are containing Android market. I run these builds on real machines (Netbooks and Slates) – and it should be possible to run it in VMs as well (although these builds doesn't support eth0).

      Addendum: Here is a forum discussion about eth0 support and market issues. As far as I have seen, Google market has the problem, that it checks for a working WiFi connection – which isn't available on a typical VM.

      HTH

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Hinweis: Bitte beachtet die Regeln zum Kommentieren im Blog (Erstkommentare und Verlinktes landet in der Moderation, gebe ich alle paar Stunden frei, SEO-Posts/SPAM lösche ich rigoros). Kommentare abseits des Themas bitte unter Diskussion.

Du findest den Blog gut, hast aber Werbung geblockt? Du kannst diesen Blog auch durch eine Spende unterstützen.