Android开发随笔技术宅android

Android通过Wifi来调试应用(win7版+局域网版)

2015-02-02  本文已影响4926人  肉团先生

Android通过Wifi来调试应用(win7版+局域网版)

我两部手机,一部开发者选项没有网络ADB试调,一部有网络ADB调试

前提:杀死使用ADB的程序,同一个局域网

开发者选项没有网络ADB调试的系统

d/adt-bundle-windows-x86_64-20131030/sdk/platform-tools

adb tcpip 5555
以上这一句话的意思是adbusb模式转化成adb网络模式(wifi
命令行相应出现:restarting in TCP mode port: 5555,代表执行成功
你会发现,手机顶端不在出现原先有的图标

打开手机连接wifi的地方,并得到wifi的地址。我的为:192.168.1.129
接着在上次一个步骤的命令行中输入
adb connect 192.168.1.129
出现:connected to 192.168.1.129:5555 代表执行成功

Paste_Image.png

adb usb
出现:restarting in USB mode 说明成功。
还原原来的状态。

开发者选项有网络ADB调试的系统

adb tcpip 5555
error: more than one device and emulator

adb connect 192.168.1.106
unable to connect to 192.168.1.106:5555

adb tcpip 5555
restarting in TCP mode port: 5555

adb connect 192.168.1.106
connected to 192.168.1.106:5555

错误

adb tcpip 5555
error:

adb connect 192.168.1.106
error:

这些情况是adb被占用了,你需要将他杀掉,然后重启

adb.exe kill-server
adb start-server

或者,情况比较悲剧,你的android系统没有安装一些必要的属性。下载msysgit,这个有什么好处呢?能用git,另外是能执行一些linux的命令来运行Linux shell。然后运行脚本来配置属性

脚本内容

E盘新建一个文件命名为adbTowifi.sh

#!/bin/bash
   
#Modify this with your IP range
#这里的ip要注意,我的是MY_IP_RANGE="192\.168\.1",这里要看你的具体ip地址决定
MY_IP_RANGE="192\.168\.43"

#You usually wouldn't have to modify this
PORT_BASE=5555

#List the devices on the screen for your viewing pleasure
adb devices
echo

#Find USB devices only (no emulators, genymotion or connected devices
declare -a deviceArray=(`adb devices -l | grep -v emulator | grep -v vbox | grep -v "${MY_IP_RANGE}" | grep " device " | awk '{print $1}'`)  

echo "found ${#deviceArray[@]} device(s)"
echo

for index in ${!deviceArray[*]}
do
echo "finding IP address for device ${deviceArray[index]}"
IP_ADDRESS=$(adb -s ${deviceArray[index]} shell ifconfig wlan0 | awk '{print $3}')

echo "IP address found : $IP_ADDRESS "

echo "Connecting..."
adb -s ${deviceArray[index]} tcpip $(($PORT_BASE + $index))
adb -s ${deviceArray[index]} connect "$IP_ADDRESS:$(($PORT_BASE + $index))"

echo
echo
done

adb devices -l
#exit

E盘,鼠标右键打开Git Bash here,然后输入

sh adbwifi.sh

出现以下效果:

Paste_Image.png

说明已经成功,这时你需要重复步骤进行配置就可以了。

参考资料

Android_ADB_通过WIFI或USB方式完成调试

上一篇下一篇

猜你喜欢

热点阅读