如何经过TCP经过ADB链接到Android?

我正在尝试在Motorola Droid上调试应用程序,可是在经过USB链接到设备时遇到了一些困难。 个人开发服务器是在Hyper-V中运行的Windows 7 64位VM,所以我没法经过客户机或主机中的USB直接链接。 git

我安装了两个不一样的USB-over-TCP TCP解决方案,可是因为ADB监视器反复报告“ devicemonitor没法启动监视”,所以链接彷佛出现了问题。 有没有一种方法可使用网络而不是USB链接或可能的其余可行选择将开发计算机上的客户端直接链接到设备上的守护程序? github


#1楼

要仅经过一个命令在TCP和USB模式之间切换,能够将其添加到/init.rcshell

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它也会触发。 服务器


#2楼

我发现其余答案使人困惑。 使用adbWireless简单得多: 网络

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

只需在手机上安装一个应用程序便可切换wifi调试,而后安装eclipse插件便可。 eclipse


#3楼

我整理了一个批处理文件,用于经过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

#4楼

使用TCP端口链接平板电脑。 确保您的系统和设备链接到同一网络。 spa

  1. 打开控制台cmd.exe
  2. 键入adb tcpip 5555
  3. 转到系统->开发选项-> USB调试 ->取消选中TCPIP链接
  4. 键入adb connect 192.168.1.2这是您的设备IP地址
  5. 链接到192.168.1.2

使用端口转发链接尝试作端口转发, 插件

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

#5楼

假设您将adb路径保存到Windows环境路径中

  1. 在Android中激活调试模式

  2. 经过USB链接到PC

  3. 打开命令提示符类型: adb tcpip 5555

  4. 断开平板电脑或智能手机与PC的链接

  5. 打开命令提示符类型: adb connect IPADDRESS (IPADDRESS是平板电脑或智能手机的DHCP / IP地址,您能够经过Wi-Fi->当前链接的网络找到该地址)

如今在命令提示符下,您应该看到以下结果:链接到xxx.xxx.xxx.xxx:5555

相关文章
相关标签/搜索