我认为有一种方法可以通过Wi-Fi测试开发中的应用程序。这可能吗?
我希望能够解开我的手机,无线开发。
我认为有一种方法可以通过Wi-Fi测试开发中的应用程序。这可能吗?
我希望能够解开我的手机,无线开发。
当前回答
我写了一个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"
其他回答
我在这里找到了答案:
Connect Android device and adb host computer to a common Wi-Fi network accessible to both. We have found that not all access points are suitable; you may need to use an access point whose firewall is configured properly to support adb. Connect the device with USB cable to host. Make sure adb is running in USB mode on host. $ adb usb restarting in USB mode Connect to the device over USB. $ adb devices List of devices attached ######## device Restart host adb in tcpip mode. $ adb tcpip 5555 restarting in TCP mode port: 5555 Find out the IP address of the Android device: Settings -> About tablet -> Status -> IP address. Remember the IP address, of the form #.#.#.#. sometimes its not possible to find the IP-address of the android device, as in my case. so u can get it using adb as the following: $ adb shell netcfg and the should be in the last line of the result. Connect adb host to device: $ adb connect #.#.#.# connected to #.#.#.#:5555 Remove USB cable from device, and confirm you can still access device: $ adb devices List of devices attached #.#.#.#:5555 device
现在可以开始了!
如果adb连接丢失:
确保你的主机仍然连接到你的Android设备所在的Wi-Fi网络。 再次执行“adb connect”步骤重新连接。 或者如果这不起作用,重置你的adb主机: 亚行kill-server
然后从头再来。
拉杜·西米内斯库的回答对我很管用。谢谢你!对于无法看到android设备ip地址的用户,请转到 >无线> Wi-Fi 然后长按已连接的wifi。然后选择“显示高级选项”上的“修改网络配置检查”,并滚动到IP地址部分。
在系统中安装adb后,请运行 Killadd adb和adb start-server 刷新adb。有时我们会遇到这样的问题
>## open command prompt with Run as Administrtor ##
adb connect ipdevice:5037
我为Windows写了一个简单的脚本:
步骤1。用以下命令创建一个批处理文件,调用wifi_dedug.bat文件并复制以下内容:
adb tcpip 5555
pause
adb shell "ip addr show wlan0 | grep 'inet ' | cut -d' ' -f6|cut -d/ -f1" > tmpFile
pause
set /p ip= < tmpFile
@echo %ip%
del tmpFile
@echo %ip%
adb connect %ip%
pause
步骤2。将您的设备连接到pc。
步骤3。启动批处理文件(按要求输入键)
步骤4。断开设备连接,通过wifi进行部署/调试。
如果你使用Android 11多次点击构建版本激活开发人员选项,然后进入设置>高级>开发人员选项。滚动到调试并打开“无线调试”复选框。点击“无线调试”打开调试菜单。选择“配对设备与配对码”,您将看到与配对码配对的地址。在你的桌面终端上写这个命令来与你的Android设备配对。
adb pair 192.168.XXX.XXX:XXXX <--------- the address showing on screen under paring code
使用配对代码进行连接。 但是等等,我们还没有连接到adb。 在您成功配对您的设备一次之后。您可以在打开无线调试选项的任何时候连接adb。从现在开始,在每次使用adb之前连接它,您不再需要配对地址,而是使用当您进入无线调试菜单时显示的给定地址。
adb connect 192.168.XXX.XXX:XXXX <--- this address shows inside wireless debug menu