我希望能够无线开发,解放手机束缚。
经过长时间的搜索,我找到了:
我必须奔跑
adb connect <device_ip_address>:5555
拔掉USB后。
我写了一个shell脚本,可以让您通过Wi-Fi调试Android设备。
以下是代码:
#!/usr/bin/env bash
#Notice: if unable to connect to [ip]:5555,
#try adb kill-server then try again.
adb shell ip route > addrs.txt
#Case 1:Nexus 7
#192.168.88.0/23 dev wlan0 proto kernel scope link src 192.168.89.48
#Case 2: Smartsian T1,Huawei C8813
#default via 192.168.88.1 dev eth0 metric 30
#8.8.8.8 via 192.168.88.1 dev eth0 metric 30
#114.114.114.114 via 192.168.88.1 dev eth0 metric 30
#192.168.88.0/23 dev eth0 proto kernel scope link src 192.168.89.152 metric 30
#192.168.88.1 dev eth0 scope link metric 30
ip_addrs=$(awk {'if( NF >=9){print $9;}'} addrs.txt)
echo "the device ip address is $ip_addrs"
echo "connecting..."
rm addrs.txt
adb tcpip 5555
adb connect "$ip_addrs"
adb connect "$ip_addrs:5555"
以使其再次正常工作。无论如何,感谢提供脚本。 - Aleksander Lech以下步骤是标准操作流程(与以前的答案大部分相同):
但在某些情况下,上述步骤会出现错误,例如“无法连接到设备。确保您的计算机和设备连接到同一WiFi网络。”而您注意到设备已经连接到同一个网络。
在这种情况下,请安装此插件“Wifi ADB Ultimate”,并按照以下步骤进行操作:
现在,您可以继续操作了!
adb tcpip 5555
会显示error: more than one device/emulator
。adb devices
已连接的设备列表
33001229 设备
emulator-5554 设备
adb -s 33001229 tcpip 5555
adb connect xxx.xxx.xxx.xxx:5555
open terminal and run the following script
adb tcpip 5555
adb connect $(adb shell ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | cut -d: -f2):5555
说明:
adb tcpip 5555
命令让设备开始监听端口5555的连接请求。
adb connect $(_ip_address_fetched_):5555
对于Windows:
步骤1. 创建一个批处理文件,包含以下命令,并将文件命名为w.bat
。
步骤2. 复制以下内容到w.bat
中,并将其保存在Windows系统的%path%
中的任何文件夹中。
echo ***Get phone in Wi-Fi mode***
echo ***Get phone in Wi-Fi mode***
adb devices
echo ***Remove cable from the phone now***
adb tcpip 9000
adb connect 192.168.1.1:9000
adb connect 192.168.1.2:9000
adb connect 192.168.1.3:9000
adb connect 192.168.1.4:9000
adb connect 192.168.1.5:9000
adb connect 192.168.1.6:9000
//<-- 到这里为止 -->
步骤 3. 使用数据线连接您的手机和电脑
步骤 4. 确保手机处于 Wi-Fi 模式
步骤 5. 当批处理文件提示您时,拔掉数据线
步骤 6. 在 Windows 命令提示符中键入 w.bat
(开始 -> 运行 -> 键入 CMD
,按下 Enter)(黑屏是 Windows DOS 命令提示符),如果您将其复制到其中一个路径文件夹中,则可以从任何位置运行,否则请从创建此文件的文件夹运行。
批处理文件的输出将类似于以下内容:
C:\Windows\System32>w
C:\Windows\System32>echo ***Get phone in Wi-Fi mode***
***Get phone in Wi-Fi mode***
C:\Windows\System32>echo ***Get phone in Wi-Fi mode***
***Get phone in Wi-Fi mode***
C:\Windows\System32>adb devices
List of devices attached
d4e9f06 device
C:\Windows\System32>echo ***Remove cable from the Phone now***
***Remove cable from the Phone now***
C:\Windows\System32>adb tcpip 9000
restarting in TCP mode port: 9000
C:\Windows\System32>adb connect 192.168.1.1:9000
unable to connect to 192.168.1.1:9000:9000
C:\Windows\System32>adb connect 192.168.1.2:9000
connected to 192.168.1.2:9000
C:\Windows\System32>adb connect 192.168.1.3:9000
unable to connect to 192.168.1.3:9000:9000
C:\Windows\System32>adb connect 192.168.1.4:9000
unable to connect to 192.168.1.4:9000:9000
C:\Windows\System32>adb connect 192.168.1.5:9000
unable to connect to 192.168.1.5:9000:9000
C:\Windows\System32>adb connect 192.168.1.6:9000
unable to connect to 192.168.1.6:9000:9000
connected to xxx.xxx.x.x:9000
C:\Users\dell>adb usb
restarting in USB mode
a. Dial *#*#4636#*#* to open the Testing menu.
b. In the Wi-Fi information menu: click Wi-Fi Status
c. Wi-Fi status can be blank for the first time
d. Click Refresh Status
e. In the IPaddr: <<IP ADDRESS OF THE PHONE IS LISTED>>
注意事项4:我的手机Wi-Fi连接IP地址范围通常如下所述的IP地址:
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
192.168.1.6
注意事项5:如果你得到任何其他序列的IP地址,这些IP地址一直被重新分配给你的手机,你可以在w.bat
文件中更改IP地址。
注意事项6:这是一种“暴力”方法,它消除了所有手动劳动,以便找到IP地址并连接到Eclipse / Wi-Fi。
成功提示7:简而言之,常规活动将是这样的:
Step 1. Connect PC and Wi-Fi via a cable
Step 2. Start CMD - to go to Windows DOS prompt
Step 3. Type "w"
Step 4. Find connected command in the output
Step 5. Success, remove cable and start using Eclipse
最好且超级简单的方法是:
adb devices
adb tcpip 5555
adb connect 192.168.9.120:5555 (你的手机IP地址为xxx.xxx.x.xxx:5555)
将此文件放在Android SDK平台工具文件夹中。 例如:C:\Users\'user_name'\AppData\Local\Android\Sdk\platform-tools
右键单击文件 > 发送到 > 桌面(创建快捷方式)
就这样……
现在,您只需要通过USB连接手机,然后打开桌面快捷方式并断开手机连接即可……
adb tcpip 5555
adb connect <DEVICE_IP_ADDRESS>:5555
adb devices
PS C:\platform-tools> adb kill-server
PS C:\platform-tools> adb shell ip route > addrs.txt
#这将为您提供TCP/IP
* daemon not running; starting now at tcp:5037
* daemon started successfully
PS C:\platform-tools> adb tcpip 5037
restarting in TCP mode port: 5037
#断开手机连接 #adb connect <phone_ip>:5037
PS C:\platform-tools> adb connect 192.168.43.1:5037
connected to 192.168.43.1:5037
现在你可以在Android Studio中查看你的手机
>## open command prompt with Run as Administrtor ##
adb connect ipdevice:5037