小米手機 adb devices 一直卡住沒有響應

發表於2024-03-01

下面的命令一直卡住

root@48c784a7f9cc:/code# adb devices -l

但是手機的埠都是 ok 的

root@48c784a7f9cc:/code# nc -zv 192.168.168.32 43267
Connection to 192.168.168.32 43267 port [tcp/*] succeeded!

我還個手機再使用 adb pair 試試,排查一下是手機的問題,還是電腦的 adb 問題

root@48c784a7f9cc:/code# adb pair 192.168.168.146:36899
Enter pairing code: 124097

換了一個手機,發現也不行

所以不是小米手機的問題,而是 adb 的問題,可能是 adb 卡死了

所以我想重啟一下 linux 上的 adb 服務

adb kill-server && adb start-server

但是發現 kill-sever 都不行,也卡住了

所以就直接 kill -9 程式吧

root@48c784a7f9cc:/code# ps jfax
   PPID     PID    PGID     SID TTY        TPGID STAT   UID   TIME COMMAND
      0 1161976 1161976 1161976 pts/3    1162004 Ss       0   0:00 bash
1161976 1161985 1161985 1161976 pts/3    1162004 S        0   0:01  \_ /usr/local/bin/python /usr/local/bin/nameko run --config config.yaml services.consumer_phone
1161985 1161987 1161985 1161976 pts/3    1162004 S        0   0:00  |   \_ /bin/sh -c adb connect 192.168.168.32:43267
1161987 1161988 1161985 1161976 pts/3    1162004 S        0   0:00  |       \_ adb connect 192.168.168.32:43267
1161976 1162004 1162004 1161976 pts/3    1162004 R+       0   0:00  \_ ps jfax
      0   12736   12736   12736 pts/2      12785 Ss       0   0:00 bash
  12736   12785   12785   12736 pts/2      12785 S+       0   0:58  \_ tail -n 1000 -f run.log
      0      24      24      24 pts/1         24 Ss+      0   0:00 bash
      0       1       1       1 pts/0          1 Ssl+     0   0:00 node /usr/local/bin/w2 run --init -z /data/ssl -p 8805
      1      13       1       1 pts/0          1 Sl+      0 3262:22 node --tls-min-v1.0 --max-http-header-size=256000 --max-semi-space-size=64 /usr/local/lib/node_modules/whistle/node_modules/starting/lib/bootstrap.js run /usr/local/lib/node_modules/whistle/index.js --data %7B%22__maxHttpHeaderSize%22%
     13      30       1       1 pts/0          1 Sl+      0 1340:17  \_ node --tls-min-v1.0 --max-http-header-size=256000 --max-semi-space-size=64 /usr/local/lib/node_modules/whistle/node_modules/pfork/lib/main %7B%22name%22%3A%22whistle.autosave%22%2C%22script%22%3A%22%2Fusr%2Flocal%2Flib%2Fnode_modul
      1      42      42      42 ?             -1 Zs       0   2:27 [adb] <defunct>
      1   12745   12743   12736 pts/2      12785 Z        0   0:00 [git] <defunct>
      1  100132  100132  100132 ?             -1 Zs       0   2:12 [adb] <defunct>
      1  332209  332209  332209 ?             -1 Zs       0   1:48 [adb] <defunct>
      1  547143  547143  547143 ?             -1 Zs       0   0:54 [adb] <defunct>
      1  655617  655617  655617 ?             -1 Zs       0   0:57 [adb] <defunct>
      1  769136  769136  769136 ?             -1 Zs       0   0:43 [adb] <defunct>
      1  855939  855939  855939 ?             -1 Zs       0   0:29 [adb] <defunct>
      1  914443  914443  914443 ?             -1 Zs       0   0:48 [adb] <defunct>
      1 1010238 1010238 1010238 ?             -1 Zs       0   0:26 [adb] <defunct>
      1 1062121 1062121 1062121 ?             -1 Ssl      0   1:19 adb -L tcp:5037 fork-server server --reply-fd 4

kill -9 之後,再重啟重啟就正常了

root@48c784a7f9cc:/code# adb kill-server && adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully

但是之前儲存的 devices 記錄都沒有了

root@48c784a7f9cc:/code# adb devices
List of devices attached
如果你想固定 adb 的埠,可以參考:adb 無線除錯固定手機的埠

更新

這個問題,我又在 mac 上遇到了,mac 的 adb 也是一樣的問題

╰─➤  adb kill-server && adb start-server                                                            130 ↵
error: failed to read response from server

mac 上的 adb 版本是

─➤  where adb                                                                                                                                          1 ↵
/opt/homebrew/bin/adb
/opt/homebrew/bin/adb
╰─➤  adb --version                                                                                                                                    130 ↵
Android Debug Bridge version 1.0.41
Version 34.0.5-10900879
Installed as /opt/homebrew/bin/adb
Running on Darwin 23.2.0 (arm64)

相關文章