我正在尝试调试摩托罗拉Droid上的应用程序,但通过USB连接到设备时遇到一些困难。我的开发服务器是一个在Hyper-V中运行的Windows 7 64位虚拟机,因此我无法在来宾或主机中通过USB直接连接。

我安装了两种不同的USB over TCP解决方案,但连接似乎有问题,因为ADB监视器反复报告“devicemonitor failed to start monitoring”。是否有一种方法可以直接从开发机器上的客户端连接到设备上的守护程序,使用网络而不是USB连接或其他可行的选项?


当前回答

首先,您必须通过USB连接设备

然后将设备连接到WIFI并获取IP地址。当仍然通过usb连接时,在命令行或通过Android Studio终端键入

adb tcpip 5555
adb connect <device IP>:5555

您将看到以下消息:

restarting in TCP mode port: 5555
connected to 172.11.0.16:5555

现在卸下USB电缆,您仍会看到logcat正常

完成。享受

其他回答

如果你的手机是根,这真的很简单。

从Google Play下载终端模拟器(有很多是免费的)。确保您的Android设备已连接到Wi-Fi,并获取Wi-Fi IP地址。打开终端程序并键入:

su
setprop service.adb.tcp.port 5555
stop adbd
start adbd

现在转到您的计算机(假设您使用的是Windows),在桌面上为“cmd.exe”创建一个快捷方式(不带引号)。

右键单击cmd快捷方式并选择“以管理员身份运行”

更改到android sdk windows\tools文件夹

类型:

adb connect ***wifi.ip.address***:5555

(example: adb connect 192.168.0.105:5555)

adb现在应该说您已连接。

注意:如果速度太快,无法发出connect命令,则可能会失败。所以,在你说这不起作用之前,至少间隔5秒试两次。

我发现其他答案令人困惑。使用adbWireless要简单得多:

http://ppareit.github.com/AdbConnect/

只需在手机上安装一个应用程序,通过wifi切换调试,安装一个eclipse插件,就完成了。

我需要让USB和TCPIP都为ADB工作(不要问),所以我做了以下工作(使用其他人从xda开发人员发布的指示)

使用adb shell:

su
#Set the port number for adbd
setprop service.adb.tcp.port 5555

#Run the adbd daemon *again* instead of doing stop/start, so there
#are two instances of adbd running.
adbd &

#Set the port back to USB, so the next time ADB is started it's
#on USB again.
setprop service.adb.tcp.port -1

exit

我确实做到了。没有使用任何usb电缆。

应用程序adb无线。运行它。这将设置ip和端口;然后在dos中cd C:\Program Files\Android\Android-sdk\platform tools adb connect“192.168.2.22:8000”enter“

有联系的。

Bash util函数:

function adb-connect-to-wifi {
    ip="$(adb shell ip route | awk '{print $9}')"
    port=5555
    adb tcpip ${port}
    adb connect ${ip}:${port}
}