[Android] 通过 Wifi 调试 adb

    xiaoxiao2023-10-16  327

    一、WIFI ADB 连接

    手机需要有ADB 权限, 也就是通过USB线能够进入ADB, 即可。

    手机 和 电脑 连接到同一个 wifi 局域网中。 察看 手机 和 电脑的wifi 地址: 举例如下: 电脑: inet addr:192.168.137.40 手机: 192.168.137.246

    此时,使用 USB 线连接手机,设置手机的port 口 (默认是5555 ) adb tcpip 5555

    拔出USB 线,开始连接手机 命令格式为: adb connect 手机IP[:端口号] adb connect 192.168.137.246 —> (可果是5555端口,可以不带port)

    adb device 看到设备时,恭喜你,说明可以使用adb 喽。

    凡事都存异常情况:

    二、如果出现 “unable to connect to IP 地址:端口号”

    进入 Android 设备终端中: $./adb shell $ su - # setprop service.adb.tcp.port 5555 # start adbd —>重启了 Android 设备 # adb tcpip 5555

    此时拔出USB 线,建立 wifi 调试连接 adb connect IP地址[:端口号]

    三、adb 连接多台机器## 二、如果出现 “unable to connect to IP 地址:端口号”

    ciellee@sh:~$ adb devices List of devices attached 192.168.137.246:5555 device LHS0118723000186 device ----> usb 线连接的第二台手机 ciellee@sh:~$ adb -s LHS0118723000186 tcpip 5555 ----> usb 线连接的第二台手机, 配置端口 restarting in TCP mode port: 5555 ciellee@sh:~$ adb connect 192.168.137.206 ----> wifi adb 连接 connected to 192.168.137.206:5555 ciellee@sh:~$ adb devices List of devices attached 192.168.137.246:5555 device LHS0118723000186 device 192.168.137.206:5555 device -------> 拔出USB线 ciellee@sh:~$ adb devices List of devices attached 192.168.137.246:5555 device ciellee@sh:~$ adb connect 192.168.137.206 connected to 192.168.137.206:5555 ciellee@sh:~$ adb shell error: more than one device and emulator ciellee@sh:~$ adb devices -l List of devices attached 192.168.137.246:5555 device product:CN_X015 model:ASUS_X015D device:ASUS_X015_1 192.168.137.206:5555 device product:LYA-AL00 model:LYA_AL00 device:HWLYA ciellee@sh:~$ adb -s 192.168.137.206:5555 shell HWLYA:/ #

    四、断开连接

    ciellee@sh:~$ adb devices -l List of devices attached 192.168.137.246:5555 device product:CN_X015 model:ASUS_X015D device:ASUS_X015_1 ciellee@sh:~$ adb connect 192.168.137.206:5555 connected to 192.168.137.206:5555 ciellee@sh:~$ adb devices -l List of devices attached 192.168.137.246:5555 device product:CN_X015 model:ASUS_X015D device:ASUS_X015_1 192.168.137.206:5555 device product:LYA-AL00 model:LYA_AL00 device:HWLYA ciellee@sh:~$ adb disconnect 192.168.137.206 ciellee@sh:~$ adb devices -l List of devices attached 192.168.137.246:5555 device product:CN_X015 model:ASUS_X015D device:ASUS_X015_1 ciellee@sh:~$

    五、 由于目标计算机积极拒绝,无法连接。 (10061)

    C:\Users\ciellee>adb connect 192.168.137.120:6666 cannot connect to 192.168.137.120:6666: 由于目标计算机积极拒绝,无法连接。 (10061)

    原因为 tcp.port 不对, 可能是因为 adb tcpip 5555 不生效,

    可以使用有线进入adb ,

    C:\Users\ciellee>adb shell msm8937_32go:/ # getprop | grep tcp.port [service.adb.tcp.port]: [5578] msm8937_32go:/ # msm8937_32go:/ # exit adb connect 192.168.137.120:5578 参考文章: https://developer.android.google.cn/studio/command-line/adb#wireless
    最新回复(0)