VirtualBox中的Android USB调试 [英] Android USB debugging in VirtualBox

查看:29
本文介绍了VirtualBox中的Android USB调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 virtualbox 上的 Windows 7 虚拟机中获得适用于 android(又名 monodroid)的单声道,但我的手机的 adb 连接出现问题.当我运行adb devices"来列出存在的设备时,它显示没有问题,但是当我尝试运行adb install"时,logcat 或 push 挂起.目前,virtualbox 中存在一个适用于此的错误,但我希望比我自己知识渊博的人有一个解决方法.

I am trying to get mono for android (aka monodroid) working within a windows 7 virtual machine on virtualbox but I am having issues with the adb connection to my phone. When I run "adb devices" to list the devices present it show up no problem, but when I attempt to run an "adb install", logcat, or push it hangs. Currently there is a bug in virtualbox which applies to this but I was hoping someone more knowledgeable than myself would have a workaround.

https://www.virtualbox.org/ticket/6620

如果 Xamarin 发布了他们产品的 linux 端口或者如果我熟悉 Java,那么粗略的非这将是一个问题,但我认为这些问题略有不同.

Of coarse non of this would be an issue if Xamarin released a linux port of their product or if I got familiar with Java, but I suppose those are slightly different issues.

推荐答案

Brian,您可能考虑的一种解决方法是让您的 VM 主机也成为 ADB 主机.然后您可以通过 TCP/IP 将您的 VM 客户端连接到它.以下是该设置的总体思路:

Brian, one workaround you might consider is to make your VM host an ADB host as well. Then you can just connect your VM client to it over TCP / IP. Here's the general idea for that setup:

  1. 在主机上安装 Android SDK.您应该只需要包含 adb 的平台工具包.
  2. 不要让您的 VM 客户端拥有 Android 设备的所有权,因此请禁用您拥有的任何 VirtualBox USB 过滤器规则,然后分离并重新连接设备也不会受到影响.
  3. 从您的 VM 客户端,运行 adb kill-server.确定它是 tskill adb.如果您有任何正在运行的 Eclipse 实例,您需要先关闭它们,因为它实际上会在后台启动 adb.不要跳过这一步.
  4. 从主机执行adb devices.如果一切顺利(应该如此),您将看到您的设备已列出.它应该看起来像这样(注意端口号并抱歉修改):

  1. Install the Android SDK on the host machine. You should only require the platform-tools package which includes adb.
  2. Don't allow your VM client to take ownership of the Android device, so disable any VirtualBox USB filter rules you have and it also wouldn't hurt to then detach and reattach the device.
  3. From your VM client, run adb kill-server. Make it a tskill adb for certainty. If you have any running instances of Eclipse, you'll want to shut those down first because it'll actually launch adb in the background. Don't skip this step.
  4. From the host, execute adb devices. If all goes well (and it should), you'll see your device listed. It should look something like this (note the port number and sorry for the mangling):

* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
015d2994ed200409    device

此时,您的主机应该有一个运行在 5037 端口的 ADB 服务器.您可以通过运行 telnet 10.0.2.2 5037 从 VM 客户端检查这一点,其中 10.0.2.2 是 VirtualBox 主机的默认 IP,5037 是上面提到的默认 ADB 端口.

At this point, your host should have an ADB server running at port 5037. You can check this from the VM client by running telnet 10.0.2.2 5037, where 10.0.2.2 is the default IP for VirtualBox hosts and 5037 is the default ADB port noted above.

  1. 现在您必须将端口从您的主机转发到您的 VM 客户端,或者以其他方式将 ADB 直接连接到您的主机 IP:port.如果你像我一样,你会发现 ADBHOST 和 ANDROID_ADB_SERVER_PORT 变量的文档很差并且很容易搞砸.出于这个原因,请考虑从 VM 客户端通过 ssh(可能通过 Cygwin)进行简单的端口转发:

  1. Now you must either forward the ports from your host to your VM client, or otherwise connect ADB directly to your host IP:port. If you're like me, you'll find the ADBHOST and ANDROID_ADB_SERVER_PORT variables to be poorly documented and easy to screw up. For this reason, consider simple port fowarding over ssh (maybe via Cygwin) like so from the VM client:

autossh -nNL5037:localhost:5037 -oExitOnForwardFailure=yes 10.0.2.2

  • 最后,从您的 VM 客户端运行 adb devices.如果您看到守护进程未运行",则表示您的端口转发已搞砸.否则,您应该会看到您的设备并能够整天登录.值得注意的一点是,您的 VM 客户端上不会运行 adb 守护进程,当然,除非您实际使用调试桥.

  • Finally, run adb devices from your VM client. If you see "daemon not running," it means your port fowarding is screwed up. Otherwise you should see your device and be able to logcat all day. One noteworthy point is that you won't have an adb daemon running on your VM client, except for when you're actually using the debug bridge, of course.

    我使用了一种类似的机制来调试通过网络连接到远程机器的设备,并且运行良好.

    I've used a similar mechanism for debugging devices over the network that are connected to remote machines and it worked well.

    这篇关于VirtualBox中的Android USB调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆