我正在尝试在Motorola Droid上调试应用程序,可是在经过USB链接到设备时遇到了一些困难。 个人开发服务器是在Hyper-V中运行的Windows 7 64位VM,所以我没法经过客户机或主机中的USB直接链接。 git
我安装了两个不一样的USB-over-TCP TCP解决方案,可是因为ADB监视器反复报告“ devicemonitor没法启动监视”,所以链接彷佛出现了问题。 有没有一种方法可使用网络而不是USB链接或可能的其余可行选择将开发计算机上的客户端直接链接到设备上的守护程序? github
要仅经过一个命令在TCP和USB模式之间切换,能够将其添加到/init.rc
: shell
on property:service.adb.tcp.port=* restart adbd on property:service.adb.tcp.enable=1 setprop service.adb.tcp.port 5555 on property:service.adb.tcp.enable=0 setprop service.adb.tcp.port -1
如今,您可使用属性service.adb.tcp.enable
启用或禁用端口5555上的侦听。运行netstat
来检查其是否在侦听。 如您所见,若是您但愿手动更改service.adb.tcp.port
它也会触发。 服务器
我发现其余答案使人困惑。 使用adbWireless简单得多: 网络
http://ppareit.github.com/AdbConnect/ less
只需在手机上安装一个应用程序便可切换wifi调试,而后安装eclipse插件便可。 eclipse
我整理了一个批处理文件,用于经过TCP自动启用ADB并将其链接到经过USB链接的设备。 有了它,您没必要手动输入IP。 tcp
@echo off setlocal REM Use a default env variable to find adb if possible if NOT "%AndroidSDK%" == "" set PATH=%PATH%;%AndroidSDK%\platform-tools REM If off is first parameter then we turn off the tcp connection. if "%1%" == "off" goto off REM Set vars set port=%1 set int=%2 if "%port%" == "" set port=5557 if "%int%" == "" set int=wlan0 REM Enable TCP adb -d wait-for-device tcpip %port% REM Get IP Address from device set shellCmd="ip addr show %int% | grep 'inet [0-9]{1,3}(\.[0-9]{1,3}){3}' -oE | grep '[0-9]{1,3}(\.[0-9]{1,3}){3}' -oE" for /f %%i in ('adb wait-for-device shell %shellCmd%') do set IP=%%i REM Connect ADB to device adb connect %IP%:%port% goto end :fail echo adbWifi [port] [interface] echo adbWifi off goto end :off adb wait-for-device usb :end
使用TCP端口链接平板电脑。 确保您的系统和设备链接到同一网络。 spa
adb tcpip 5555
adb connect 192.168.1.2
这是您的设备IP地址 使用端口转发链接尝试作端口转发, 插件
adb转发tcp: <PC port>
tcp: <device port>
喜欢:
亚行转发tcp:5555 tcp:5555。
C:\\ Users \\ abc> adb转发tcp:7612 tcp:7612
C:\\ Users \\ abc> adb tcpip 7612在TCP模式下从新启动端口:7612
C:\\ Users \\ abc> adb connect 10.0.0.1:7612
已链接至10.0.0.1:7612
若是收到消息错误:找不到设备,则将USB设备链接到系统,而后执行相同的步骤。
对于有根设备
setprop service.adb.tcp.port 5555 stop adbd start adbd
假设您将adb路径保存到Windows环境路径中
在Android中激活调试模式
经过USB链接到PC
打开命令提示符类型: adb tcpip 5555
断开平板电脑或智能手机与PC的链接
打开命令提示符类型: adb connect IPADDRESS
(IPADDRESS是平板电脑或智能手机的DHCP / IP地址,您能够经过Wi-Fi->当前链接的网络找到该地址)
如今在命令提示符下,您应该看到以下结果:链接到xxx.xxx.xxx.xxx:5555