Friday, April 13, 2018

Debug ios and Android application using wifi connection

The usb connector on android or iOS device may wear out after a while, and the connection to device gets dropped frequently when rotating the device. Or the mac may not have enough USB port to connect all devices. In those cases, it is useful to use wifi connection for debug


Android
Android studio supports wiki connection to device for debugging, and it can be done with below steps:
1. connect device using USB connection
2. set the device to listen for a tcpip connection on port 5555 from terminal
adb tcpip 5555
3. disconnect the device usb connection
4. find the device ip address from device's Settings > About tablet (or About phone) > Status > IP address screen
5. connect the device using tcpip connection
adb connect YourDeviceIPAddresss
6. confirm the device is connected using wifi connection
adb devices
7. start the debug from android studio and your device will be ready to use in same way as usb connection.

Note when you start Android Device monitor, it will disconnect the device connected by wifi. In that case, you will need to run
adb connect YourDeviceIPAddresss
again to reconnect to your device.

In addition, the below adb command can be used to let application wait to start until a debugger is attached. It is useful to debug the app starting code

adb shell am set-debug-app -w com.mypackage.myapplication


iOS
It is much simple to do wifi debug on iOS
1. First connect the device via USB to MAC
2. Open Device and Simulator window under Xcode's Window menu
3. select your device, and then check the "Connect via network" checkbox
4, unplug the USB cable



No comments:

Post a Comment