How to connect multiple android devices with ADB over wifi

允我心安 提交于 2019-12-20 14:14:41

问题


ADB is installed in the computer, and usb debugging is enabled on devices. Also I have connected one device over wifi successfully. How to connect more devices without having to mention the serial number of the device for every additional device with the -s flag like: adb -s <serial> tcpip <port>


回答1:


Yes there is a way to do so without having to type the serial number.

Say you have 2 devices A (IP: 192.168.1.32) and B (IP: 192.168.1.33) that you want to connect to ADB over wifi:

  1. Connect device A with a USB cable to the computer (but not B)
  2. adb -d tcpip 5555
  3. adb connect 192.168.1.32
  4. Disconnect device A, and connect device B with a USB cable to the computer
  5. adb -d tcpip 5555
  6. adb connect 192.168.1.33



回答2:


A slight change in the Abdul Wasae answer, based on my experience .

devices A (IP: 192.168.1.32)

devices B (IP: 192.168.1.33)

Connect device A with a USB cable to the computer (but not B)

adb -d tcpip 5555

adb connect 192.168.1.32

Disconnect device A, and connect device B with a USB cable to the computer,This time you need to change the port !!

adb -d tcpip 5554

Here you need to specify port as well

adb connect 192.168.1.33:5554

I also have documented this here in more detail Connecting multiple devices over wifi using adb




回答3:


I have this problem long time ago so I decided to create this simple bash script.

Assuming that you already added the adb to the path:

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

You just need to follow this steps:

  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
    


来源:https://stackoverflow.com/questions/43973838/how-to-connect-multiple-android-devices-with-adb-over-wifi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!