Step by step
1. 将手机和电脑连接到同一个wifi下;
2. 将电脑和手机用usb线连接;
3. 设置wifi调试端口为5555
adb tcpip 5555
4. 查看手机ip
adb shell "ifconfig | grep -A 1 wlan0 | tail -n 1 | cut -f2 -d: | cut -f1 -d' '"
5. 断开usb连接, 然后创建连接
假设手机ip为192.168.1.222
adb connect 192.168.1.222:5555
大功告成!~
附:
shell命令具体解释:
ifconfig
查看网络接口信息

grep -A 1 wlan0
搜索包含"wlan0"所在的一行 以及它的下一行(Append)

tail -n 1
输出末尾一行

cut -f2 -d:
以:
作为分隔符切割字符串, 同时选取第二段输出

cut -f1 -d:
以空格
作为分隔符切割字符串, 同时选取第一段输出

网友评论