华为荣耀手机 {HUAWEI Honor V9} USB 调试 - ADB 调试
- 1. 开发者模式
- 2. USB debugging (USB 调试)
- 3. ADB 连接设备
- 4. Windows 启动 adb server
- 5. 其他主机用户连接 devices
- 6. Troubleshooting 1
- 7. Troubleshooting 2
- References
1. 开发者模式
Settings (设置) -> System (系统) -> About phone (关于手机) -> Build number (版本号)
连续点击 Build number (版本号) 7 次进入 开发者模式。
You are already a developer!
您正处于开发者模式!
2. USB debugging (USB 调试)
Settings (设置) -> System (系统) -> Developer options (开发人员选项) -> USB debugging (USB 调试)
- USB 调试 - ENABLE (连接 USB 后开启调试模式)
- 连接 USB 时总是弹出提示 - ENABLE
- 选择 USB 配置 - MTP (多媒体传输)
3. ADB 连接设备
Microsoft Windows [版本 10.0.19041.450]
(c) 2020 Microsoft Corporation. 保留所有权利。
C:\Users\cheng>adb kill-server
C:\Users\cheng>adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
C:\Users\cheng>adb devices
List of devices attached
FFKDU17A28006357 device
C:\Users\cheng>adb shell
HWDUK:/ $ exit
C:\Users\cheng>
adb devices [-l]
- list connected devices (-l
for long output)
列出链接的设备 (-l
for long output)
Microsoft Windows [版本 10.0.19041.450]
(c) 2020 Microsoft Corporation. 保留所有权利。
C:\Users\cheng>adb devices
List of devices attached
FFKDU17A28006357 device
C:\Users\cheng>
C:\Users\cheng>adb devices -l
List of devices attached
FFKDU17A28006357 device product:DUK-AL20 model:DUK_AL20 device:HWDUK transport_id:1
C:\Users\cheng>
adb kill-server
- kill the server if it is running
Microsoft Windows [版本 10.0.19041.450]
(c) 2020 Microsoft Corporation. 保留所有权利。
C:\Users\cheng>adb kill-server
C:\Users\cheng>
C:\Users\cheng>adb kill-server
cannot connect to daemon at tcp:5037: cannot connect to 127.0.0.1:5037: 由于目标计算机积极拒绝,无法连接。 (10061)
C:\Users\cheng>
C:\Users\cheng>adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
FFKDU17A28006357 device
C:\Users\cheng>
C:\Users\cheng>adb kill-server
C:\Users\cheng>
4. Windows 启动 adb server
adb kill-server
adb -a -P 5037 nodaemon server
或者
adb kill-server
adb -a nodaemon server
-a
- listen on all network interfaces, not just localhost - 侦听所有网络接口,而不仅仅是本地主机
-H
- name of adb server host [default=localhost]
-P
- port of adb server [default=5037]
adb -a nodaemon server
- 启动守护进程后,其他用户可以通过 adb -H 192.168.*.*** devices
和 adb -H 192.168.*.*** shell
访问 192.168.*.***
挂载的手机。
NOTE: Linux 和 Windows 中的 adb 版本要完全相同。
Microsoft Windows [版本 10.0.19041.450]
(c) 2020 Microsoft Corporation. 保留所有权利。
C:\Users\cheng>adb kill-server
C:\Users\cheng>adb -a nodaemon server
adb I 04-30 19:53:44 15496 12640 auth.cpp:417] adb_auth_init...
adb I 04-30 19:53:44 15496 12640 auth.cpp:152] loaded new key from 'C:\Users\cheng\.android\adbkey' with fingerprint C003CF5AD89F690A49BB31A1FB606378F31F0772F9ED77D67B67921478710B0E
adb I 04-30 19:53:44 15496 10268 transport.cpp:325] FFKDU17A28006357: read thread spawning
adb I 04-30 19:53:44 15496 13656 transport.cpp:297] FFKDU17A28006357: write thread spawning
adb I 04-30 19:53:44 15496 12640 transport.cpp:1527] fetching keys for transport FFKDU17A28006357
adb I 04-30 19:53:44 15496 12640 auth.cpp:469] Calling send_auth_response
adb I 04-30 19:53:44 15496 12640 adb.cpp:124] FFKDU17A28006357: offline
adb -a nodaemon server
执行前,先执行 adb kill-server
。
Microsoft Windows [版本 10.0.19041.450]
(c) 2020 Microsoft Corporation. 保留所有权利。
C:\Users\cheng>adb devices
List of devices attached
FFKDU17A28006357 device
C:\Users\cheng>
C:\Users\cheng>adb -a nodaemon server
adb F 08-29 18:13:43 14532 12896 main.cpp:153] could not install *smartsocket* listener: cannot bind to 0.0.0.0:5037: 閫氬父姣忎釜濂楁帴瀛楀湴鍧€(鍗忚/缃戠粶鍦板潃/绔彛)鍙厑璁镐娇鐢ㄤ竴娆°€?(10048)
C:\Users\cheng>
C:\Users\cheng>adb kill-server
C:\Users\cheng>
C:\Users\cheng>adb -a nodaemon server
adb I 04-30 19:53:44 15496 12640 auth.cpp:417] adb_auth_init...
adb I 04-30 19:53:44 15496 12640 auth.cpp:152] loaded new key from 'C:\Users\cheng\.android\adbkey' with fingerprint C003CF5AD89F690A49BB31A1FB606378F31F0772F9ED77D67B67921478710B0E
adb I 04-30 19:53:44 15496 10268 transport.cpp:325] FFKDU17A28006357: read thread spawning
adb I 04-30 19:53:44 15496 13656 transport.cpp:297] FFKDU17A28006357: write thread spawning
adb I 04-30 19:53:44 15496 12640 transport.cpp:1527] fetching keys for transport FFKDU17A28006357
adb I 04-30 19:53:44 15496 12640 auth.cpp:469] Calling send_auth_response
adb I 04-30 19:53:44 15496 12640 adb.cpp:124] FFKDU17A28006357: offline
5. 其他主机用户连接 devices
(base) yongqiang@yongqiang:~$ adb -H 192.168.0.109 devices
List of devices attached
FFKDU17A28006357 device
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ adb -H 192.168.0.109 shell
HWDUK:/ $ cd /data/local/tmp/
HWDUK:/data/local/tmp $ ls -l
total 0
HWDUK:/data/local/tmp $ exit
(base) yongqiang@yongqiang:~$
6. Troubleshooting 1
1.
netstat -ano | findstr "5037"
进程 15496 占用了 5037 端口。
C:\Users\cheng>netstat -ano | findstr "5037"
TCP 0.0.0.0:5037 0.0.0.0:0 LISTENING 15496
C:\Users\cheng>
2.
tasklist | findstr "15496"
使用命令查看这个进程是由哪个程序的 adb.exe
创建了 15496 进程。
C:\Users\cheng>tasklist | findstr "15496"
adb.exe 15496 Console 7 10,704 K
C:\Users\cheng>
3.
taskkill /f /pid 15496
结束掉 15496 进程。
7. Troubleshooting 2
Microsoft Windows [版本 10.0.19043.1645]
(c) Microsoft Corporation。保留所有权利。
C:\Users\cheng>adb kill-server
cannot connect to daemon at tcp:5037: cannot connect to 127.0.0.1:5037: 由于目标计算机积极拒绝,无法连接。 (10061)
C:\Users\cheng>adb -a nodaemon server
adb I 05-04 17:12:43 16096 21124 auth.cpp:417] adb_auth_init...
adb I 05-04 17:12:43 16096 21124 auth.cpp:152] loaded new key from 'C:\Users\cheng\.android\adbkey' with fingerprint C003CF5AD89F690A49BB31A1FB606378F31F0772F9ED77D67B67921478710B0E
如果启动 adb server 时出现上述 log,请查看 2. USB debugging (USB 调试)
进行设置。
References
[1] Yongqiang Cheng, https://yongqiang.blog.csdn/