简体   繁体   English

在Android模拟器中调试物理USB设备

[英]Debugging physical USB Device in Android Emulator

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. 我问类似问题的原因是,自问这个问题以来已经过去了六年,而Android在那段时间已经进步了很多。

I'm writing an Android app that interfaces with a USB device, and I need to see debugger information when the two interact. 我正在编写一个与USB设备连接的Android应用,当两者交互时,我需要查看调试器信息。 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. 我可以通过USB将物理Android手机连接到我的开发机,以在logcat中查看调试信息,也可以将手机连接到USB设备,但显然不能同时使用。

I'm open to other solutions, but is there currently a way to make an Android Virtual Device recognize a physical USB device? 我对其他解决方案持开放态度,但是目前是否有一种方法可以使Android虚拟设备识别物理USB设备?

Developing on Windows 10 64-bit with Android Studio 2.3.3. 使用Android Studio 2.3.3在Windows 10 64位上进行开发。 The development machine does not have Wi-Fi capabilities, as per company policy. 根据公司政策,开发机器不具有Wi-Fi功能。 If there are answers for other operating systems, or involving wireless connectivity please share them anyway, as they may help others in the future. 如果有其他操作系统的答案,或者涉及无线连接,请随时分享它们,因为它们将来可能会帮助其他人。

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. 我可以通过USB将物理Android手机连接到我的开发机,以在logcat中查看调试信息,也可以将手机连接到USB设备,但显然不能同时使用。

The typical solution would be to use adb over WiFi , so your Android phone's USB port is free. 典型的解决方案是通过WiFi使用adb ,因此Android手机的USB端口是免费的。

If your phone has a USB-C port, it's conceivable that you could use a USB-C hub. 如果您的电话具有USB-C端口,则可以使用USB-C集线器。 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的Raspberry Pi作为您的Android测试环境,通过以太网设置adb (与通过WiFi相同的方法),并使用Pi的USB端口作为设备。 Android Things isn't exactly the same as Android on mobile devices, but it may be close enough for your use case. Android Things与移动设备上的Android并不完全相同,但对于您的用例而言,它可能已经足够接近了。

You could try other Android hardware that offers an Ethernet port plus USB (eg, Amazon Fire TV, Samsung Galaxy S8 in a DeX dock) or offers separate USB host and USB accessory ports. 您可以尝试其他提供以太网端口和USB的Android硬件(例如,Amazon Fire TV,DeX扩展坞中的Samsung Galaxy S8)或提供单独的USB主机和USB附件端口。

but is there currently a way to make an Android Virtual Device recognize a physical USB device? 但是目前是否有一种方法可以使Android虚拟设备识别物理USB设备?

Not that I am aware of. 不是我知道的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM