安卓手机在开发者模式下 打开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
相关推荐
Billy_Zuo11 分钟前
Android Studio中创建第一个Flutter项目
android·flutter·android studio
RabbitYao25 分钟前
Google TextToSpeech apk 添加离线语音包再重新编译
android
w23617346012 小时前
Android四大核心组件
android·四大组件
Dnelic-2 小时前
移动通信行业术语
android·telephony·自学笔记
每次的天空3 小时前
Android学习总结之扩展基础篇(一)
android·java·学习
心之所向,自强不息3 小时前
关于Android Studio的Gradle各项配置2
android·gradle·android studio
EQ-雪梨蛋花汤3 小时前
【Flutter】Unity 三端封装方案:Android / iOS / Web
android·flutter·unity
foenix664 小时前
PicoVR眼镜在XR融合现实显示模式下无法显示粒子问题
android·unity·c#·xr·pico
一杯凉白开5 小时前
为了方便测试,程序每次崩溃的时候,我都让他跳转新页面,把日志显示出来
android