问题
From what I know, android emulator cannot listen to USB or any other devices of Hosting machine, and thus I have a question: Is there any way to emulate USB connections (or any other device connection like headphones or microphone) on an Emulator? Maybe through adb or emulator command tools? Or maybe there is a way to have the emulator see devices connected to the host (PC, Windows OS)?
My application has an option menu where all connected audio devices are listed, and the user can choose from this list. However, for Android TV I'm using an emulator and I can't connect new devices to test it out.
回答1:
Do you use emulator on Ubuntu? If yes, try:
- list the usb device use lsusb, e.g. for my logictech wireless keyboard and mouse dongle
Bus 002 Device 002: ID 0424:5744 Standard Microsystems Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 023: ID 046d:c534 Logitech, Inc. Unifying Receiver
- start the emulator
sudo ./emulator @Pixel_XL_API_Q -kernel /home/robot/Android/goldfish/arch/x86/boot/bzImage -qemu -usb -device usb-host,hostbus=1,hostaddr=23
- now you can switch the keyboard and mouse to the emulator
That works for me
https://www.linux-kvm.org/page/USB_Host_Device_Assigned_to_Guest
will give you some infos.
回答2:
You can use virtualbox with an android image.
来源:https://stackoverflow.com/questions/53205809/connecting-usb-devices-to-android-emulator