我认为有一种方法可以通过Wi-Fi测试开发中的应用程序。这可能吗?
我希望能够解开我的手机,无线开发。
我认为有一种方法可以通过Wi-Fi测试开发中的应用程序。这可能吗?
我希望能够解开我的手机,无线开发。
当前回答
虽然有这么多好的答案,这里是我对未来的我的两点意见:P和任何想要快速简单的人。
Mac:
首先使用USB连接设备,并确保调试工作正常。断开任何其他设备并退出模拟器。 打开终端,运行以下脚本 Adb tcpip 5555 Adb connect $(Adb shell ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | cut -d: -f2):5555 断开USB连接,设备应可进行WiFi调试
解释:
Adb tcpip 5555命令设备开始监听端口5555上的连接
Adb connect $(_ip_address_fetched_):5555表示连接到_ip_address_fetched_地址的5555端口
其中_ip_address_fetched_包含以下内容:
Adb shell ifconfig使用Adb shell获取Internet配置
Grep "inter "过滤任何以inter开头的行
排除本地主机。
此时,输出应该是这样的:
inet addr :###.###.#.# # #广播地址 :###.###.#.# # #面具:255.255.255.0
awk '{print $2}'获取组件数组的第二部分,用空格分隔(我使用zsh)。
到此为止的输出是
addr :###.###.#.###
Cut -d: -f2用分隔符分割字符串,然后取第二部分。它只会接收你的设备IP地址
其他回答
如果你想在设备上启用无线adb,而不需要连接USB线(root要求):
在设备上安装终端应用程序(如Android终端模拟器) 输入以下内容 苏 Setprop service.adb.tcp.port 5555 停止adbd 开始adbd
因为你已经打开了终端,你可以找到设备的IP地址:
ip addr show
然后在调试环境中运行命令:
adb connect ip.of.the.device
这将使该设备被列为您可能拥有的任何其他模拟器。请注意,在重置设备之前,TCP将保持打开状态。 如果你经常断网,你可能还想安装一个Wi-Fi Keep Alive应用程序。
如果你想要安全,记得在连接到公共网络时关闭TCP。您可以执行以下操作或简单地重新启动设备:
苏 Setprop service.adb.tcp.port -1 停止adbd 开始adbd
我写了一个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"
2021年8月编辑
谷歌用ArcticFox Beta 03 https://issuetracker.google.com/issues/190411383删除了它,但在Android Studio Bumblebee它仍然存在。看起来他们有很多问题,这就是为什么它只是金丝雀版本
最初的发布
这个Android WiFi ADB插件不能在4.1.1中工作(不再)
但有一个更简单的解决方案: 如果你有Android 11 (api30)设备,你应该使用Android Studio 2020.3.1 (Canary)来连接。非常简单
然后进入开发者设置,扫描二维码。就是这样。 你现在也可以在其他(旧的)Android Studio版本中使用连接设备
1-为此,我认为你已经安装了最新版本的Android studio。如果没有,你可以从这里下载。
2 -可以在“环境变量”中设置平台工具路径(可选)。
3 -确保你的设备和电脑连接到同一个网络。
plug in the data cable from pc to device. Now, type adb tcpip 5555 remove data cable. Then type adb connect 192.168.43.95 here 5555 is the port number and 192.168.43.95 is the ip address of the mobile device you can get id address from the mobile settings . Then go to About device and go to status you can see the ip address of the device. You can connect multiple device from different ports which can give ease in development. Or you can go to this link for brief description with screenshots. http://blogssolutions.co.in/connect-your-android-phone-wirelessly-by-adb
first you shold connect your device with usb to pc after that run cmd and drag and drop adb.exe that is in sdk/platform-tools path and write below code :
....\Sdk\platform-tools\adb.exe devices
.....\Sdk\platform-tools\adb.exe tcpip 5555
.....\Sdk\platform-tools\adb.exe connect Ip address:5555