3

How do you get adb devices to work from within a virtualbox virtual machine?

(note- I installed VS 2015 redistributable https://www.microsoft.com/en-us/download/details.aspx?id=53587 for adb devices to not give an error about a missing DLL, on my win7 VM , otherwise it would at least on win7. I installed adb from https://developer.android.com/studio/releases/platform-tools )

As you can see, outside the VM, it lists the smartphone connected to my physical computer.

But within the VM, it can't see it

enter image description here

ADDED

I see that with VirtualBox you have to do a bunch of things to get USB recognised. Like check what version of virtualbox it is (in my case 6.0.4), going here https://www.virtualbox.org/wiki/Download_Old_Builds_6_0 downloading the "extension pack" for my virtualbox version, installing it so it shows in virtualbox's file..preferences..extensions. Doing device..insert guest additions cd image, installing that. Shutting down the VM. Going to I've now done that. Clicking the VM, going to machine..settings.. usb Then clicking the little square where the USB devices pop up. I selected my USB device(s) that I want my VM to see. I started up the machine.

The USB sockets I am using are USB3, they are marked with SS next to the USb symbol.. In VirtualBox machine..settings..usb, where it says USB2, USB3.. I tried USB3 but they didn't show. Then I tried USB2 and that worked. (i.e. shutting down the VM, so USB settings are not greyed out, picking USB2, then starting the VM).

The VM is now seeing the smartphone. And a USB stick I plugged in. (So, seen by VM, not by physical computer).

But adb devices within the VM, is still not listing the device.

I tested it on another phone(Moto G7 Power) , same thing. Got the VM to view it, but adb devices doesn't list it.

In the image below, both windows there, the computer window showing the smartphone, and the cmd window with adb devices not seeing the smartphone, are windows of the VM. And same thing happens with a different make/model smartphone too.

enter image description here

2
  • Are you passing the USB device through to your VM?
    – Karu
    Commented Jan 15, 2021 at 2:44
  • @Karu I wasn't. I'll look into how to do that. Thanks
    – barlop
    Commented Jan 15, 2021 at 2:45

2 Answers 2

2

ADB in this fashion is tied to your USB, so your VM needs to be able to see the USB device. However, this is an either/or operation. Either your device is tied to your host machine, or it's tied to the VM - not both.

Ensure that your VM has a USB controller added in its hardware configuration, and that Virtualbox Guest Additions are installed in the VM.

Once you've done this, you'll see a USB icon at the bottom of your VM's window. Click on that, then select your Android device to give control of it to the VM.

VirtualBox window

1
  • thanks, see my update.. maybe you can see if a VM and adb devices can see your phone?
    – barlop
    Commented Jan 15, 2021 at 5:41
0

From what I understand: adb in the vm opens a server at another port. It is not compatible with the adb outside the VM. So, you have to make sure that it is not connected to the system outside the VM and busy there. (Try disconnect usb first, then connect using the virtualbox menu, see screen of @Karu). If it isn't connected to the host system, you can start adb devices and authorize this adb session on the connected device.

(got here by search, and this way it worked for me, thanks for your groundwork)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .