I want to debug my android application, I connect the android device to my PC using the USB cable. In my application there is a button to connect with localhost, ip for loca
I think you have two options
The first one is using 10.0.2.3 when you use your real android device.it works for me.
Your Second opt is creating hotspot from your pc and connect your android device to the hotspot.
Find the ip address using cmd type "ipconfig" replace localhost with the ip address.
Thanks.