Monday, December 26, 2011

Using adb to install Apps on Android x86 4.0.1 Ice Cream Sandwich in VirtualBox


Android 4.0 Ice Cream Sandwish - ICS
ADB means Android Debug Bridge which is part of Android SDK. This tool allows you to communicate Android devices or emulator with command line in Terminal window. It will be very helpful to install android apps (.apk) on Android Virtual Machine even without Android Market. The adb.exe can be obtain from SDK Platform Tools. I found a VMLite build Android Virtual Machine from the Android ICS 4.0.1 source code, Ice Cream Sandwich. They also provided the adb.exe and sdcard.vdi together inside the 7z archive. Most important of all, the Internet connection works.

What you will need:
  1. VirtualBox
  2. Android v4

Let's begin:
    Creating Android virtual machine and mount fake SD card

  1. Extract Android-v4.7z.
  2. Open VirtualBox.
  3. Add new machine, choose Linux as Operating System and Other Linux as Version.
  4. VirtualBox - Create Android 4.0 Ice Cream Sandwich ICS
  5. Choose Use existing hard disk, click Choose a virtual hard disk file icon and open Android-v4.vdi.
  6. VirtualBox - Android Virtual Hard Disk
  7. Click Create.
  8. VirtualBox - Android VM Summary
  9. You have created a Android virtual machine. Now mount the SD card virtual disk image, click Settings, click Storage. Click Add Hard Disk icon which is beside IDE Controller, open sdcard.vdi. Set Android-v4.vdi as Master and sdcard.vdi as Slave.
  10. VirtualBox - Android Settings
  11. To allow Android Debug Bridge (adb) connect to Android Virtual Machine, still on the Settings page, click Network, under adapter 1 tab, click Port Forwarding button, enter 5555 into host and guest's port number and OK.
  12. VirtualBox - Port Forwarding Rules
  13. The configuration in VirtualBox is done. Your Android virtual machine is ready to start. In this stage, it has Internet network and mounted a 8GB fake SD card.

    Installing apps using adb

    I can't direct install apps (.apk) downloaded on Android ICS virtual machine. So, we use adb to install apps on Android virtual machine. Step 7 is very important.

  14. First, download a .apk file you want to install on put it into Android-v4 folder. For example, I want to install Android Terminal Emulator. I put the Terminal Emulator Term.apk file into Android-v4 folder.
  15. Open VirtualBox and start Android virtual machine.
  16. After that, press Shift key + right click on Android-v4 folder, then click Open command window here.
  17. To connect adb to Android Virtual Machine, enter this command: adb connect localhost
  18. adb has connected to Android Virtual Machine, I can now install Android Terminal Emulator by this command: adb install term.apk
  19. If you get the error "more than one device and emulator", use this to install: adb -s localhost:5555 install term.apk (Thank you Javier)
    Android Debug Bridge - adb install
  20. Wait until the Success word appears and voila the Terminal Emulator application is installed on Android virtual machine.
  21. VirtualBox - Android 4.0 Ice Sandwich ICS Menu
Enjoy and have fun exploring the Android ICS 4.0.1

80 comments:

  1. Are you using AMD CPU? It seems AMD CPUs are getting this error in this build. Hope VMLite will update it very soon. If you're interested, you may try another Android .vdi here. Hopefully it will supports AMD.

    ReplyDelete
  2. cannot get it to work. it freezes during boot and says "[6.540970] atkbd.c: Spurious ACK on isa0060/serio0. Some program might be trying to access hardware directly." what should I do

    ReplyDelete
  3. when I try to 
    adb install anything.apk it gives me "error: more then one device and emulator"
    I am doing it exactly the way you described it in your tutorial I don't know what the problem is.

    ReplyDelete
  4. Seem to have accidentally fixed my problem lool but now I seem to have run into another problem, it says success in the installations of APKs now but it wont show up in the virtual box.

    ReplyDelete
  5. This error appears because you might have multiple virtual machines. Increase the Android host port to 5556 or higher should do the job. =)

    ReplyDelete
  6. That's weird. I haven't faced this problem so far. Even the incompatible APK installed on my Android Virtual Machine will have its icon shows up on the menu.

    ReplyDelete
  7. It means your Android Virtual Machine is not connected to adb. Make sure you have extracted everything from Android-v4.7z and put all files into the same folder.

    ReplyDelete
  8. i get the error:
              This kernek requires the following features not present on the CPU:
              pae
              Unable to boot - please use a kernel appropriate for your CPU.
    i'm running an asus netbook with 2 GB ram and a Intel Atom CPU N450 (1.66 GHz).
    here is the entire screen if i quickly switch to the "Install" option:
                   Booting 'Android Install to /dev/sda from /dev/sdb'
              cmdline (hd1,0)/cmdline
              Error 17: cannot mount selected partition
              Press any key to continue...
    is there anything i can do to fix this, or am i out of luck?

    ReplyDelete
  9. Try this. Select your Android Virtual Machine > Settings > System > Processor > Enable PAE/NX > OK

    ReplyDelete
  10. what is the advantage of this over running it in the emulator that comes with the android sdk

    ReplyDelete
  11. Android-x86 4.0 test build is not perfect. Problem occurs while direct install some Android app. So we use adb to help us go through the installation. I haven't test the newer RC build. Hope they have fixed it.

    ReplyDelete
  12.  when I try to 
    adb install anything.apk it gives me "error: more then one device and emulator"
    I am doing it exactly the way you described it in your tutorial I don't know what the problem is.

    Can you please show me a clean way to face this...
    Even if i connect to localhost:5556 I get the same error

    ReplyDelete
  13. I use command: "adb devices" and i get two:
     
    emulator-5554    device
    localhost:5555    device

    What to do?

    ReplyDelete
  14. This is better because it is FAST. Insanely fast, because it is a native x86 version of the Android operating system which your PC can run just like any other program.

    The emulator that comes with Android SDK is SLOW because it is ARM-based (because almost all mobile devices that currently run Android are arm based), so your PC is emulating an entirely new set of hardware

    ReplyDelete
  15. where is v4 folder located ?

    ReplyDelete
  16. i am using andriod ics image file and installed it in my vhd and created a fake sd card after that i have already installed terminal emulator on my device but dont know how to transfer or install files from my pc ? can you clearify the steps please...................

    ReplyDelete
  17. where do i copy the file that is to be installed in andriod ics

    ReplyDelete
  18. v4 folder is the location where Android-v4.7z you extracted.

    ReplyDelete
  19. I am also using AMD.. have tried both the VDI's .. also tried installing on virtual box.. no success.. same error..

    ReplyDelete
  20.  did you succedded with this vdi??

    ReplyDelete
  21. VMLite haven't found the solution for this. The v4 has issues on some CPUs. Hope they will release 4.0.3 version soon. It might fix the problem.

    ReplyDelete
  22. supercoolkavya@gmail.comApril 4, 2012 at 11:00 PM

    i have done as you said upto step 9 but i get error message when i start virtualbox andriod it says at last " Unable to boot please use a kernel appropiate for your pc ?"

    ReplyDelete
  23. supercoolkavya@gmail.comApril 4, 2012 at 11:01 PM

    how to open cmd by shift key + right click it doesn,t show any option for command window can you help me

    ReplyDelete
  24. On Virtualbox, try click Edit > Settings > System > Processor > Enable PAE.

    ReplyDelete
  25. Shift + Right click on your extracted folder (Android v4.7) and you will get the Open Command Window option.

    ReplyDelete
  26. Supercoolkavya@gmail.comApril 5, 2012 at 4:41 PM

    when i open cmd from v4 folder then i copied the file my beach hd to v4 folder and given the command connect to localhost it connected succesfully but after i gave command to install adb install my  beach hd.apk it says more than one virtual devices or emulator

    ReplyDelete
  27. Do you have more than one virtual machine?

    It works fine for me when I use 5556 for host port and 5555 for guest port (Android is my second virtual machine) which can be configure in Port Forwarding.

    ReplyDelete
  28. This must be a win7 thing in xp >start>all programs>accessories>command prompt cd \(full path)\Android-v4
    eg
    E: (if you have it on another drive)
    cd \VirtualBox VMs\Android-v4

    ReplyDelete
  29. Thanks a lot, this works very well for me (mac w/ virtualbox).
    One question though is it possible to change the screen resolution ?  I'm developing for tablets and the ratio of this display is really off.

    ReplyDelete
  30. That's cool. Have you tried Android-x86 from www.android-x86.org? They have build for tablets.

    ReplyDelete
  31. how to transfer music files to sd card..

    ReplyDelete
  32. supercoolkavya@gmail.comApril 23, 2012 at 12:56 AM

    is says the app has benn unfortunetly stopped i think its because of high screen resolution how to swithch to smaller size

    ReplyDelete
  33. supercoolkavya@gmail.comApril 23, 2012 at 12:57 AM

    lease replay fast icannoct play wheres my water which i have installed it says the app wheres my water hass unfortunetly stopped working

    ReplyDelete
  34. This Android build on is still problematic at the moment. Have you tried the Android-x86 RC build? It might have better system stability.

    ReplyDelete
  35. Hi, I have just try the installation and the Android ICS works great on my HP intel machine. however there is no sound coming out from the Android and how can i get google play on the Android ICS so that can try out some games

    ReplyDelete
  36. Oops! I didn't test the sound. You can download and install apps/games in .apk format without Google Play. But I doubt that most games will work properly because the current Android builds are still buggy on x86 machines.

    ReplyDelete
  37. supercoolkavya@gmail.comApril 23, 2012 at 7:17 PM

    say the solution what to do when i open 9mm hd which is wvga game it runs fine but when i open a smaller screen size gays it doesnt run how to transfer files to sd card

    ReplyDelete
  38. Got ICS running smoothly but zero internet capabilities.  Been messing around with the virtualbox network settings but with no luck.
    Got a Marvel Yukon 88E8040 PCI-E & Intel Wireless WifI link 4965AGN both connected to the same network any help would be much appreciated

    ReplyDelete
  39. I have got the Internet running on VirtualBox with another Android ICS vdi.
    http://keyable.blogspot.com/2011/12/run-android-40-ice-cream-sandwich-on.html 

    ReplyDelete
  40. I get an error saying "Some program might be trying access hardware directly."

    ReplyDelete
  41. Hi, make sure you have turn on cpu hardware virtualization.

    ReplyDelete
  42. You can find it in your Android Virtualbox settings. System > Acceleration and enable VT-x/AMD-V.

    ReplyDelete
  43. I suspect the Intel VT-x or AMD-V might not be supported on your computer.

    ReplyDelete
  44. Sir, When i'm trying typing this command , adb install term.apk, i got error messages "error: more than one device and emulator" can you solve me, what's the problem

    ReplyDelete
  45. Hi Marlon, try the command below to connect.



    adb –s localhost:5555 shell


    Hopefully adb should connect the right device.

    ReplyDelete
  46. I just found a solution. Enter 5555 into host's port and guest's port. Connect adb and Android VM with the following command:


    adb –s localhost:5555 shell

    ReplyDelete
  47. Works like a charm. I do have one question. is it possible not to have it in landscape mode. i've got an app that only works in portrait.

    ReplyDelete
  48. Hi Thomas Seberechts , you can use the Android 4.0.4 by Buildroid which has better support for VirtualBox. It will auto-rotate if an app requires to work in portrait mode.

    ReplyDelete
  49. please, add this to step 13.
    if you get the error "more than one device and emulator", use this to install:

    adb -s localhost:5555 install term.apk

    ReplyDelete
  50. i did installed the android-x86 to my hdd... can i used it as emulator with eclipse?

    ReplyDelete
  51. I never tried. It should be able to use with Eclipse.

    ReplyDelete
  52. Hi everyone
    i have done with procedure defined above but when i use to start machine the it is giving error 15: File not found
    press any key to continue....
    when i press some key it going to start option


    Help me please

    ReplyDelete
  53. It works very well. But I found a problem when trying to install WhatsApp on the system. It says " a cellular data network is required to activate WhatsApp messenger ". Any idea how to solve that :) ?

    ReplyDelete
  54. Thank you for additional info. Added to step 13.

    ReplyDelete
  55. on adb, type:


    adb push .../music.mp3 /sdcard/

    ReplyDelete
  56. It says Error: device not found when I type adb install (apk name).apk ):

    ReplyDelete
  57. adb was not connected to your Android VM. Make sure the host and guest ports are 5555 as shown on step 7. Try connect it again with this command: adb connect localhost:5555

    ReplyDelete
  58. I have never install WhatsApp messenger on Android VM but it seems it needs cellular network to verify your details first.

    ReplyDelete
  59. Are you using AMD processor?

    ReplyDelete
  60. Okay, I did what you said and now it says Device offline. Wut is going on D: Please help! I've been trying for days ]:

    ReplyDelete
  61. Hi, I'm having the same problem, the only thing is that Intel VT-x is already turned on and it still says the same thing.

    ReplyDelete
  62. True. How to enable such cellular network on the machine. That's the thing :)

    ReplyDelete
  63. viber.apk is not installing in this virtual machine... :( :( :(

    ReplyDelete
  64. reply me how to install this.... pls...

    ReplyDelete
  65. Hi, I've installed viber.apk but the app stopped after I launched it. I guess this is a limitation of Android on x86. Not all Android apps are supported on x86.

    ReplyDelete
  66. It works very well. But I found a problem when trying to install App on the system. It says "
    Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY] ". Any idea how to solve that :) ?

    ReplyDelete
  67. What was the app you trying to install? I googled and found this might answer your question. Using adb logcat should to able to find the cause of the installation error.


    Also check out the newer Android 4.0.4 optimized for VirtualBox which I found the best way to use Android on VirtualBox.

    ReplyDelete
  68. Open folder in command window with single click from explorer go





    http://www.windows-commandline.com/2011/07/open-command-window-here.html

    ReplyDelete
  69. install C:\test\GingerBreak-v1.20.apk

    1621 KB/s (302325 bytes in 0.182s)

    Error: Could not access the Package Manager. Is the system running?



    WHAT TO DO ?? @green_lemon:disqus

    ReplyDelete
  70. i got failure [INSTALL_FAILED_CONTAINER_ERROR]
    what the solution

    ReplyDelete
  71. it say 'cant find 'term.apk' to install' when i'm trying to enter adb -s localhost:5555 install term.apk

    ReplyDelete
  72. unfortunately app has stopped....why..???/

    ReplyDelete
  73. I have reduced the screen resolution but the problem stays "unfortunetly XXX has stopped" !!!! Is there any solution for this problem ???

    ReplyDelete