android connect to PC's localhost when debugger on mobile device

前端 未结 5 933
梦谈多话
梦谈多话 2020-12-05 10:36

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

5条回答
  •  天涯浪人
    2020-12-05 11:07

    As 10.0.2.2 is your system (pc)'s local host address (from emulator only). Actually android doesn't recognized localhost in url. so 10.0.2.2 is for that meant. Also for android device loopback address is 127.0.0.1.

    Your url with 10.0.2.2 is correct. Also you can use Static IP of your system.

    Just check for

    
    

    in your application's manifest file.

    EDIT:

    Here you are using port 8080 so, try with adb command on your host machine.

    adb forward tcp:8080 tcp:8080
    

    Also please elaborate on this line "i want to debugger my application on my mobile".

    Note:

    If you are going to test on real device use your Network IP of system (PC).

提交回复
热议问题