安卓手机在开发者模式下 打开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
相关推荐
齊家治國平天下1 小时前
Android 14 Input 事件派发机制深度剖析
android·input·hal
2501_916013742 小时前
iOS 推送开发完整指南,APNs 配置、证书申请、远程推送实现与上架调试经验分享
android·ios·小程序·https·uni-app·iphone·webview
李艺为4 小时前
非预置应用使用platform签名并且添加了android.uid.system无法adb安装解决方法
android·adb
李宥小哥6 小时前
C#基础11-常用类
android·java·c#
高工智能汽车10 小时前
棱镜观察|极氪销量遇阻?千里智驾左手服务吉利、右手对标华为
人工智能·华为
Jerry11 小时前
Compose 中的绘制功能简介
android
我科绝伦(Huanhuan Zhou)12 小时前
【脚本升级】银河麒麟V10一键安装MySQL9.3.0
android·adb
消失的旧时光-194312 小时前
Android回退按钮处理方法总结
android·开发语言·kotlin
叫我龙翔13 小时前
【MySQL】从零开始了解数据库开发 --- 数据表的约束
android·c++·mysql·数据库开发