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

前端 未结 5 930
梦谈多话
梦谈多话 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:04

    Google has added support in Chrome 29 and higher to use reverse port forwarding to access a website hosted on your local development machine through the USB cable on Chrome for Android. Setup instructions can be found at the following URL:

    • Android Remote Debugging - Reverse Port Forwarding
    • Tools for Web Developers - Access Local Servers

    As of desktop Chrome 30 Reverse Port Forwarding is no longer an experimental feature in Chrome. It can be accessed by typing about:inspect in the address bar of your PC, and by clicking the "Enable port forwarding" check box and clicking the "Configure port forwarding" button located to the top right of the window.

    Once that is done, connect your mobile device via USB. Open Chrome on your mobile device to localhost:8000 (or whichever port you have configured on your local server).

    The Reverse Port Forwarding functionality will make sure that your Android device now sees your PC's localhost.

提交回复
热议问题