1

Note: The closest other question I've found is here. The reason I'm asking something similar is because six years have passed since that question was asked, and Android has advanced quite a bit in that time.

I'm writing an Android app that interfaces with a USB device, and I need to see debugger information when the two interact. I can connect my physical Android phone to my development machine via USB to view debugging info in logcat, or I can connect the phone to the USB device, but obviously not both at the same time.

I'm open to other solutions, but is there currently a way to make an Android Virtual Device recognize a physical USB device?

Developing on Windows 10 64-bit with Android Studio 2.3.3. The development machine does not have Wi-Fi capabilities, as per company policy. If there are answers for other operating systems, or involving wireless connectivity please share them anyway, as they may help others in the future.

automaton
  • 495
  • 6
  • 16
  • 2
    If you have WiFi access, you can connect to a device via adb over WiFi: https://developer.android.com/studio/command-line/adb.html#wireless Not sure if you can get a developer exception to the company policy. Alternatively get a Android development board which will normally have multiple USB connectors. For example: https://developer.qualcomm.com/hardware/additional-snapdragon – Morrison Chang Nov 06 '17 at 19:32

1 Answers1

3

I can connect my physical Android phone to my development machine via USB to view debugging info in logcat, or I can connect the phone to the USB device, but obviously not both at the same time.

The typical solution would be to use adb over WiFi, so your Android phone's USB port is free.

If your phone has a USB-C port, it's conceivable that you could use a USB-C hub. I have never tried this.

You could use a Raspberry Pi running Android Things as your Android test environment, setting up adb over Ethernet (same approach as over WiFi) and using the Pi's USB ports for the device. Android Things isn't exactly the same as Android on mobile devices, but it may be close enough for your use case.

You could try other Android hardware that offers an Ethernet port plus USB (e.g., Amazon Fire TV, Samsung Galaxy S8 in a DeX dock) or offers separate USB host and USB accessory ports.

but is there currently a way to make an Android Virtual Device recognize a physical USB device?

Not that I am aware of.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • The particular phone does not have a USB-C Port, so I can't verify this, but I'm skeptical a hub would work in this configuration. That would mean the phone would simultaneously have to function as a host (for the peripheral) and a device (for the debugger). As far as separate host and accessory ports, USB doesn't distinguish, and relies on the protocol to sort out who's who when the initial handshake occurs. If anyone has the hardware on hand and wants to try, the hub method feel free to share you results – automaton Nov 07 '17 at 17:03
  • So using USB for both is probably not possible. The answer would have to lie in connecting the Debugger through a separate method, like Ethernet or Wi-Fi for those who can do so. The main question was "Can I pipe USB to a Virtual Device," and if the answer is indeed no I will close the question after another day or two – automaton Nov 07 '17 at 17:11