Debugging Android application when Android device is connected with a USB device

Let’s say, you are developing an Android application that will be using a finger print scanner and it will be connected with the android device through OTG cable. In this situation you can not use USB debugging option as you are unable to connect to computer via USB cable. Remote debugging through network solves this problem. To enable remote debugging of your Android device do the followings.

1. Connect to your Android device via USB to your computer. Go to your sdk-dir/platform-tools/ directory and from command prompt run adb devices to check whether USB debugging is working.

2. Run adb tcpip 5555

3. Get the IP address of your Android device, from the device menu or by running the command adb shell netcfg

4. Disconnect your Android device from computer.

5. Run adb connect [device-ip-address]:5555 to connect your Android device remotely. Now you could run the commands like adb logcat to get logs in the command prompt or save logs to a file by running the command adb logcat > logs.txt

6. You could switch back to USB debugging mode by running adb -s [device-ip-address]:5555 usb

If somehow connection is lost, make sure that the host computer and the Android device is connected with the same wi-fi network and reconnect by adb connect step again. If the previous option does not work reset your adb host by running adb kill-server and execute the steps again.

Leave a Comment

Your email address will not be published. Required fields are marked *