Connection to LocalHost/10.0.2.2 from Android Emulator timed out

前端 未结 3 928
长发绾君心
长发绾君心 2020-12-06 17:40

Although this question has been asked multiple times in StackOverflow and I went through many of them, still I couldn\'t resolve my issue or I am not able to find out the ro

相关标签:
3条回答
  • 2020-12-06 18:02

    Why to go for localhost or any ip address to run on emulator or real device simply go for ngrok to convert the localhost as a global address with very convenient and simplest way.

    0 讨论(0)
  • 2020-12-06 18:03

    Making a connection from your Android to your Computer is working with 10.0.2.2 only on an Google Android Virtual Device. Android Virtual Devices are listening for 10.0.2.2 and forwarding all the requests to your computer.

    Genymotion Android Virtual Devices are listening on 10.0.2.3 and forwarding those requests to your computer.

    10.0.2.2 is not working with your real Android device. If you want to use it with your real device you have to set the IP of your computer, as it has been suggested by a previous answer.

    0 讨论(0)
  • 2020-12-06 18:14

    I have figured out the reason why it was not working. There were two issues --

    1. The IP Address was not correct. So I changed the IP Address from 10.0.2.2 to the IPv4 address - which can be obtained on windows by typeing ipconfig in the command prompt and see link for linux.

    2. Also the port number 8080 was not correct. I have set my own port number in httpd.conf file, like ##Listen 12.34.56.78:8383Listen 0.0.0.0:8383Listen [::0]:8383##, under Apache and I used the same.

    After changing both and re-starting the WAMP server, it worked like a charm.

    0 讨论(0)
提交回复
热议问题