Android 模拟器 USB 直通失败:“‘usb-host’不是有效的设备型号名称”

2023-12-25

当我尝试使用 USB 直通时,如中所述https://androidstudio.googleblog.com/2020/08/emulator-30024-canary.html https://androidstudio.googleblog.com/2020/08/emulator-30024-canary.html,

emulator -avd Pixel_3a_API_30_x86 -qemu -usb -device usb-host,vendorid=076B,productid=3821

我收到错误消息'usb-host' is not a valid device model name。根据 Google 链接,模拟器版本 30.0.24 应该支持 USB 直通,而我的模拟器报告版本 30.5.3.0 (build_id 7196367)。

有没有人成功地让它发挥作用?


不!与 Android 模拟器版本 30.5.4.0 (build_id 7243153) 相同。

如果我查看 Linux 版本的 qemu 模拟器文件的二进制文件,
我仍然可以找到 usb-host 选项。但它完全被排除在外 在 Windows 版本中。
所以我猜 Google 一定已经切换了 USB 主机 Windows 中的支持关闭。
不幸的是,模拟器的最新发行说明是 从30.4.5(2021年2月23日) https://developer.android.com/studio/releases/emulator#other_new_features_and_enhancements

我也找不到任何关于此的提示android-review AOSP https://android-review.googlesource.com/q/usb-host+qemu不知道还能去哪里看!?

[更新:]
我想我已经在 GitHub AOSP Mirror 上找到了它android-review AOSP https://android-review.googlesource.com/c/platform/external/qemu/+/1611183。 Erwin Jansen 于 3 月 3 日承诺:

恢复“为 Windows 启用 USB 主机重定向” https://github.com/aosp-mirror/platform_external_qemu/commit/92ec8e5214f9c54130601e8007838e9169d4a514

# Libusb support on windows is not what we would like it to be
LIBUSB_FLAGS="--disable-libusb --disable-usb-redir"

Windows 上的 USB 直通功能似乎有太多问题。
所以,如果有人能回到版本 30.5.2(内部版本号 7175973) https://dl.google.com/android/repository/emulator-windows_x64-7175973.zip(2021 年 2 月 27 日)
USB 主机仍然是有效的设备型号名称。
DL 取自加那利海峡 https://github.com/tadfisher/android-nixpkgs/blob/c4aa702506046c4015e626aa993065bbb5d0b469/channels/canary/default.nix.

但谷歌似乎仍然working https://android-review.googlesource.com/c/platform/external/qemu/+/1555478在上面...

[21.12.10更新]
自模拟器版本 31.1.4 以来,google 实现了一些新功能和工具 通过USB。 我找不到-列出USB https://android-review.googlesource.com/c/platform/external/qemu/+/1761045/4参数与模拟器-帮助,但它的工作原理 如果你运行:

emulator -list-usb
VID:PID 058f:6387 (Bus 1, Port 5.1.1)
        Manufacturer:
        Product:
        SerialNumber:   40A0FE0A

有了这些信息,您可以使用-usb 直通 https://android-review.googlesource.com/c/platform/external/qemu/+/1761967/6/android/android-emu/android/help.c#2038范围
(-usb 直通供应商 ID=VID,产品 ID=PID[,主机总线=总线,主机端口=端口])

emulator -netdelay none -netspeed full -avd Pixel_4_API_31 -usb-passthrough vendorid=058f,productid=6387,hostbus=1,hostport=5.1.1

但它显示错误:

ERROR   | Cannot load Android USB Assistant Driver for USB device "vendorid=058f". USB pass-through might not work.

谷歌再次添加了一个新工具,用于 USB 直通的预构建 Windows 驱动程序 https://android-review.googlesource.com/c/platform/external/qemu/+/1786589/3人们可以再试一次。可直接从AOSP https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-31-release/android/third_party/usbpassthrough-prebuilt-win32/ (tgz)

以管理员身份运行:

Install_Drivers.bat
Installing Android USB Assistant...
call Android_USB_Assistant_Install.bat
Microsoft PnP Utility

Processing inf :            Android_USB_Assistant.inf
Successfully installed the driver.
Driver package added successfully.
Published name :            oem89.inf


Total attempted:              1
Number successfully imported: 1

Installing Android Emulator USB Passthrough Assistance Driver

SERVICE_NAME: UsbAssist
        TYPE               : 1  KERNEL_DRIVER
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
[SC] DeleteService SUCCESS

SERVICE_NAME: UsbAssist
        TYPE               : 1  KERNEL_DRIVER
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 0
        FLAGS              :

但再次尝试,仍然显示相同的错误。

[21.12.13更新]
现在它正在发挥作用。正确的语法是0x并且没有 usbhost 和 usbport 关键字:

-usb-passthrough vendorid=0x058f,productid=0x6387

它仍然显示错误消息:

qemu-system-x86_64.exe: libusb_kernel_driver_active: -12 [NOT_SUPPORTED]

并且 AVD 无法识别该设备, 但一旦你用我的脚本root了AVD(Magisk Canary)rootAVD https://github.com/newbit1/rootAVD来自Github 与参数PATCHFSTAB GetUSBHPmodZ

rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-32\google_apis_playstore\x86_64\ramdisk.img PATCHFSTAB GetUSBHPmodZ

并安装我的 usbhostpermissions.zip Magisk 模块,USB 驱动器将 在系统范围内显示为驱动器,并且可以访问 USB 串行设备 通过 USB 串行终端 Apk。 APK USB 设备信息还将 现在显示已连接的 USB 设备。我会更新我的XDA指南 https://forum.xda-developers.com/t/guide-build-mod-avd-kernel-android-10-11-rootavd-magisk-usb-passthrough-linux-google-play-store-api.4212719/尽快 因此。

为了传递更多 USB 设备,只需在第一个 USB 设备后面添加另一个即可,即:

emulator -netdelay none -netspeed full -avd Pixel_4_API_32 -usb-passthrough vendorid=0x058f,productid=0x6387 -usb-passthrough vendorid=0x067b,productid=0x2303
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android 模拟器 USB 直通失败:“‘usb-host’不是有效的设备型号名称” 的相关文章

随机推荐