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

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

问题描述

我想获得单声道为Android(又名monodroid)上的VirtualBox中的窗口工作7虚拟机,但我有我的电话亚行连接问题。当我运行亚行的设备列出的设备present它显示没有问题,但是当我试图运行亚行安装,logcat中,或将其挂起。目前有适用于这个在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.

推荐答案

布莱恩,你可能会考虑一个解决办法是让你的VM主机亚行的主机也是如此。然后你就可以在你的虚拟机客户端只需连接到它通过TCP / IP。下面是安装程序的总体思路:

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。您应该只需要平台的工具包,其中包括亚洲开发银行
  2. 请不要让你的虚拟机客户端采取了Android设备的所有权,因此禁用您有任何VirtualBox的USB过滤规则,它也不会伤害然后卸下并重新安装设备。
  3. 从你的虚拟机客户端,运行 ADB杀死服务器。使它成为一个 TSKILL亚行的确定性。如果您有Eclipse的任何正在运行的情况下,你要关闭那些先坐下,因为它实际上将推出亚洲开发银行的背景。不要跳过此步骤。
  4. 从主机,执行 ADB设备。如果一切顺利的话(它应该),你会看到你的设备上市。它应该是这个样子(注意端口号和遗憾,识别码):

  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):

*守护进程没有运行。现在在端口5037启动它* *守护进程启动成功* 设备名单附后 015d2994ed200409设备

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

在这一点上,您的主机应该有一个ADB服务器的端口5037.运行时,您可以通过运行检查这个由虚拟机客户端的telnet 10.0.2.2 5037 ,其中 10.0.2.2 是默认IP为VirtualBox虚拟主机和 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. 现在您必须从您的主机的端口转发到你的虚拟机客户端,或以其他方式直接连接亚行到你的主机IP:端口。如果你像我一样,你会发现ADBHOST和ANDROID_ADB_SERVER_PORT变量进行记录不完整,容易搞砸了。为此,可以考虑简单的端口fowarding了 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:本地主机:5037 -oExitOnForwardFailure =是10.0.2.2

最后,运行 ADB设备从你的虚拟机客户端。如果你看到守护程序没有运行,这意味着你的端口fowarding被搞砸了。否则,你会看到你的设备,并能logcat中一整天。一个值得注意的一点是,你不会有一个亚洲开发银行守护您的虚拟客户机上运行,​​除了当你实际使用过程中的调试桥。

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.

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

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