如何通过wifi连接多个安卓设备使用ADB

13

电脑上已安装ADB,并已启用设备的USB调试。同时我已成功通过Wi-Fi连接一个设备。如何连接更多设备,而不必像这样在每个附加设备上使用-s标志来指定设备的序列号:adb -s <serial> tcpip <port>

3个回答

33

是的,有一种方法可以在无需键入序列号的情况下完成此操作。

假设你有两个设备A(IP:192.168.1.32)和B(IP:192.168.1.33),你想通过WiFi连接到它们的ADB:

  1. 使用USB电缆将设备A连接到计算机(但不要连接设备B)
  2. adb -d tcpip 5555
  3. adb connect 192.168.1.32
  4. 断开设备A的连接,并使用USB电缆将设备B连接到计算机
  5. adb -d tcpip 5555
  6. adb connect 192.168.1.33

8

根据我的经验,Abdul Wasae的答案稍作修改。

设备A(IP:192.168.1.32)

设备B(IP:192.168.1.33)

使用USB电缆将设备A连接到计算机(但不要连接B)

adb -d tcpip 5555

adb connect 192.168.1.32

断开设备A的连接,并使用USB电缆将设备B连接到计算机,这时需要更改端口!!

adb -d tcpip 5554

在这里,您需要指定端口号

adb connect 192.168.1.33:5554

我在这里也有更详细的文档记录:通过adb连接多个设备的wifi


好奇,你为什么需要改变端口呢?在我的情况下,使用相同的端口值5555可以很好地工作。 - wood wood

1

我很久以前就遇到了这个问题,所以我决定创建这个简单的bash脚本

假设您已将adb添加到路径中:

export PATH=${PATH}:/home/YOUR-USERNAME/path/to/adb

您只需要按照以下步骤进行:

  1. Run this commands: to create your script (typically, you want $HOME/bin for storing your own scripts)

    cd ~
    mkdir bin
    cd bin
    touch adb_connect
    
  2. Open and copy the script using any editor like gedit.

    gedit adb_connect
    
  3. And make your file executable.

    sudo chmod +x adb_connect
    
  4. Modify your path to add the directory where your script is located:

    export PATH=$PATH:$HOME/bin
    
  5. Finally, now connect your device using USB and run the script:

    adb_connect
    
  6. Your device must be connect now, disconnect the USB cable and repeat steps 5 and 6 to add more devices. If a successful connection occurs, it will have this output:

    Connecting to LGV498bdcb2c5
    restarting in TCP mode port: 7105
    connected to 192.168.20.105:7105
    

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接