Android devices will be connected with PC using the USB cable for debugging or running the automation script for the mobile application testing. But you could connect the device in wireless itself using the WLAN (Wireless Local Area Network). Wi-Fi will be used to connect the device instead of USB data cable.
Before kick-starting the wireless connect using ADB(Android Debug Bridge) in the Android SDK, the appropriate device USB driver should be installed in the PC and here I tried in a windows x86 machine with windows 7 operating system. One Plus 3 Android device used for wireless connect in this posting. Once connected my android device in PC using the USB data cable, One Plus 3 USB driver got installed automatically based on the pre-configured auto-run feature available in the mobile device.
Please note, USB driver installation requirement is applicable for Windows x86/x64 machines and the Linux based machines will be having its own USB driver to handle any mobile devices.
Windows PC and Android device should be connected in the same WLAN network and you could cross-verify the IP address of both the devices in which it should be in the same IP range. If you see my PC IP is 192.168.1.34 and my Android device IP is 192.168.1.33. Try to get the windows PC IP using ‘ipconfig’ in the command prompt and verify the Android device IP as follows;
- Go to ‘Settings’ in the Android device
- Select the ‘About Phone’ option
- Select the ‘Status’ option
- You could see the IP address of the device in the same screen (Please note your device should be connected in Wi-Fi and IP address will be auto-assigned by Router)
Connect the Android device with the PC using the USB cable and try to execute the below command and verify whether the device is connected and ready to move forward. In the below screenshot, One Plus 3 device got listed out with its device ID.
You cannot directly connect the Android device by using the IP address assigned in the WLAN. Port should be assigned to the Android device using the adb command and it is possible when the device connected with the PC using USB data cable. Already you’ve verified whether the device got identified by adb command or not using the above screenshot. Now, we are going to assign a port to the Android device using the below command;
adb tcpip <port>
adb tcpip 5656
Please note <port> is user-defined and you can enter any number other than the pre-allocated port number like 80, 22 etc.
Once port number assigned, adb will try assigning that port to Android device and restarting the connection. Please unplug the Android device from the USB data cable and now your device is ready to connect wirelessly using the below command.
adb connect <IP Address>:<port>
adb connect 192.168.1.33:5656
That’s it, your device got connected and ready to debug or run your automation script in the android device under wireless mode.
Please note, 5555 port number is allocated by default. If you assign the port number as 5555 using the adb tcpip 5555 command then you can just give ‘adb connect 192.168.1.33’ and there is no need to mention about the port number.
In the above screenshot, I’ve tried to connect the IP address without port number and with port number. Getting ‘Unable to connect’ without port number tried to connect the default port number which 5555 but assigned 5656 port to the mobile device. After that, tried with the assigned port number 5656 and it is getting connected.
You can connect multiple devices by assigning a separate port for each device using the adb tcpip <port> command and save your day by avoiding USB HUB 🙂 I tried with three different Android devices such as One Plus 3, Sony Xperia XA and Motorola E 4G and all the devices got listed after executing the ‘adb devices’ command as follows;
List of devices attached
192.168.1.33:5656
192.168.1.35:5657
192.168.1.37:5658
Good post .
LikeLike
Very useful. Steps well documented with examples. The best part is it tells how to handle specific issues.
LikeLike