Use Android Devices for Guest Ubuntu OS in VirtualBox on Windows 7 Host

Developing Android applications can be done completely on Windows. That’s good for a Windows user. Sometimes, there are certain features in the tool chain that are only available on Linux. For occasional use of such purposes, it makes sense to run a Linux guest OS in a virtual machine, such as in Oracle VirtualBox, where the building environment is truly Linux. This is in contrast to the effort to set up a real Linux box.

VirtualBox and VMware have built-in support for sharing files and directories between a virtual machine guest OS and the host OS. It is sufficient to have the guest Linux to cross-build for Android, share back the built binaries, and from Windows host we can adb push the binaries to the Android hardware devices.

To experiment with somewhat authentic Linux based Android development, it is interesting to see if we can do all the Android development steps on a virtual Linux machine running in VirtualBox on a Windows 7 host, including using a real Android device than AVD. The pick of Linux is latest Ubuntu 12.10.

In general, unlike on Windows, on Linux there is no device driver to be installed for Android devices for Android development purpose. Ubuntu is however an exception, and in addition since our Ubuntu is not running on a physical box, it also needs extra setup on VirtualBox VM too. Below is a step by step guide.

  • Install VirtualBox and matching Extensions Pack. The Extensions Pack is mandatory for USB support.
  • Create and install a virtual machine in VirtualBox for Ubuntu 12.10 (see also a previous post for installing Ubuntu and Android Development Environment in VirtualBox). From the VM’ Settings, choose USB, and check Enable USB Controller, check Enable USB 2.0 (EHCI) Controller, then add USB Device Filters. For my Motorola DEFY XT557, I just add Vendor ID 22b8 (see picture below). When such a USB device plugs into the system, VirtualBox will take the control and provide driver for Windows host. So Windows will believe this is a USB device “manufactured and driven” by VirtualBox, and does not bother to install other (and real manufacturer’s) Windows driver. (In fact, I was not able to install the Windows driver for Motorola DEFY XT557 downloaded right from Motorola website, but I am able to adb with the phone through Ubuntu in VirtualBox without Motorola’s driver!)


  • If you have other devices, you can find the USB Vendor IDs at Android Developer’s Using Hardware Devices page. Or, you can also use VirtualBox’s VBoxManage tool to list all the USB devices visible on host (see command line below). By plugging/unplugging the device and checking the difference in the listings, you will find out the device information.

    C:\Program Files\Oracle\VirtualBox>VBoxManage list usbhost

  • Run the Ubuntu VM in VirtualBox, and create a udev rules file for the device:

    my_user_name@my-ubuntu:~$sudo gedit /etc/udev/rules.d/51-android.rules
my_user_name@my-ubuntu:~$sudo chmod a+r /etc/udev/rules.d/51-android.rules

    In the text editor gedit, make sure the rules file to have a line like below:

    SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="my_user_group"

  • Enable USB debugging on the Android device. See Setting up a Device for Development.2.
  • Re-insert your device to a USB port.
    • You should see some message like “Installing VirtualBox USB device” on Windows Notification Area (for the first time).
    • From your Ubuntu terminal

        my_user_name@my-ubuntu:~$android-sdk-linux/platform-tools/adb devices
        * daemon not running. starting it now on port 5037 *
        * daemon started successfully *
        List of devices attached
        TBEN2247512345  device

        Therefore adb sees the Android phone attached to the computer. From here you can use the real device in your Android development with a virtual Ubuntu!

If you do not see any device listed with adb devices, or if you see a device but it says ???????????? no permissions, you will need to double-check that the steps above are done correctly.

About these ads

2 Responses to “Use Android Devices for Guest Ubuntu OS in VirtualBox on Windows 7 Host”

  1. I had an issue where my phone prompted me to accept the connection. I’m using a Samsung Galaxy Note 2. Otherwise, the instructions were just fine. Also, I was able to add a filter by simply choosing my Galaxy Note 2 from a list, and it auto configured.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 35 other followers

%d bloggers like this: