安卓手机在开发者模式下 打开wifi调试功能的相关 adb 命令

文章目录

Intro

部分安卓手机的开发者模式中,只提供了 USB调试模式,却没有明显的 wifi调试模式的相关菜单。

前置条件

  • 手机已经打开开发者模式
  • 已经安装好Android Studio,或者已经配置了adb工具的所在路径到了环境变量。
  • 手机和电脑连接同一个Wi-Fi。

以下以华为手机为例:

核心步骤已标注了1, 2, 3, 4

shell 复制代码
wuyujin1997@wyjmacm1 debug % adb devices -l           
List of devices attached
2HSYD24327214065       device 0-1.4.1 product:FGD-AL00 model:FGD_AL00 device:HWFGD-H transport_id:8
192.168.3.117:6666     device product:FGD-AL00 model:FGD_AL00 device:HWFGD-H transport_id:7

wuyujin1997@wyjmacm1 debug % adb tcpip 5555
error: more than one device/emulator
wuyujin1997@wyjmacm1 debug % adb kill-server
wuyujin1997@wyjmacm1 debug % adb status
adb: unknown command status
wuyujin1997@wyjmacm1 debug % adb start-server


# 第一次是从这里开始。
# 1. USB 连接安卓手机和电脑,执行 adb devices 列出已连接的安卓设备
wuyujin1997@wyjmacm1 debug % adb devices -l
List of devices attached
2HSYD24327214065       device 0-1.4.1 product:FGD-AL00 model:FGD_AL00 device:HWFGD-H transport_id:1

# 2. 执行 adb tcp <port>  命令
wuyujin1997@wyjmacm1 debug % adb tcpip 5555
restarting in TCP mode port: 5555
wuyujin1997@wyjmacm1 debug % adb devices
List of devices attached
2HSYD24327214065	device

# 3. tcpip之后先不要拔USB线。先执行connect。
# ip: 如何查看华为手机的IP?【设置】---【关于手机】---【状态信息】---【IP地址】
# port: 刚才 tcpip 你用了哪个port,现在就用哪个port。
wuyujin1997@wyjmacm1 debug % adb connect 192.168.3.117:5555
connected to 192.168.3.117:5555
wuyujin1997@wyjmacm1 debug % adb devices -l
List of devices attached
2HSYD24327214065       device 0-1.4.1 product:FGD-AL00 model:FGD_AL00 device:HWFGD-H transport_id:2
192.168.3.117:5555     device product:FGD-AL00 model:FGD_AL00 device:HWFGD-H transport_id:3

# 4. 拔USB线,然后列出设备。可以发现只剩下 ip:port 形式的设备。
wuyujin1997@wyjmacm1 debug % adb devices -l
List of devices attached
192.168.3.117:5555     device product:FGD-AL00 model:FGD_AL00 device:HWFGD-H transport_id:3

wuyujin1997@wyjmacm1 debug % adb devices -l
List of devices attached
192.168.3.117:5555     device product:FGD-AL00 model:FGD_AL00 device:HWFGD-H transport_id:3

确认

如何确认我们的确通过 wifi连接的方式 用adb连接了安卓手机和电脑呢?

如果已经连接成功,是可以执行相关的adb命令的。随便找一条,试试命令结果正常与否?

比如:

shell 复制代码
wuyujin1997@wyjmacm1 ~ % adb shell pm list packages
package:com.huawei.hifolder
package:com.android.cts.priv.ctsshim
package:com.huawei.camera
package:com.huawei.android.tips
package:com.huawei.camerakit.impl
package:com.huawei.synergy
package:com.huawei.android.launcher
package:com.android.providers.telephony

好处

USB连接调试是有线,wifi是无线,更方便。

wifi连接通了之后,在手机上设置好。之后每次要安装新的app到手机(或其他操作),不需要重新走一遍配对连接流程。

只需要以下命令即可重连、确认。

shell 复制代码
adb connect <ip>:<port>

adb devices -l
相关推荐
小孔龙3 小时前
GraphicBuffer 跨进程共享
android
行业研究员4 小时前
Android内置GPS与腾讯地图定位技术对比分析
android·android定位·腾讯地图定位
daad7774 小时前
用 HackRF + GNU Radio 抓取并解析 5 GHz Wi‑Fi 帧:从理论到 pcap 落地
wifi·802.11·gnuradio·beacon
云端漫步19874 小时前
HarmonyOS 互动卡片实战:快递卡片与睡眠卡片完整开发流程
华为·harmonyos
Android-Flutter4 小时前
android WMS 详解(二)
android·kotlin
智塑未来5 小时前
鸿蒙6.1隐私安心加倍:加密分享、星盾防诈、应用锁三重保护,守护到位
华为·harmonyos
游戏开发爱好者85 小时前
App Store 上传 IPA 自动化,.p8 密钥认证与 CI/CD 接入实战
android·运维·ci/cd·小程序·uni-app·自动化·iphone
游戏开发爱好者86 小时前
iOS 推送怎么配置,APNs 推送证书、设备库与群发
android·ios·小程序·https·uni-app·iphone·webview
阿pin7 小时前
Android随笔-kotlin 高阶函数
android·kotlin·高阶函数
wxson728221 小时前
【Android视频监控系统技术总结】
android·音视频