Connecting USB Devices to Android Emulator

て烟熏妆下的殇ゞ 提交于 2021-01-05 11:14:17

问题


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:

  1. 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
  1. 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
  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!