Android: Volley NoConnectionError

前端 未结 4 1149
不知归路
不知归路 2021-01-06 06:48

I\'m trying to connect to a REST-Server (which I created with Spark) via Android. I can send POST-Requests with POSTMAN (Chrome Addon) and get what I want, but when I try to

相关标签:
4条回答
  • 2021-01-06 06:49

    Android emulator uses 10.0.2.2 as a host loopback interface. Use it instead of 127.0.0.1 which is emulator itself.

    0 讨论(0)
  • 2021-01-06 07:04

    127.0.0.1 is the loopback ip address on your android device. You need the ip address of your computer. I presume you 're running on an emulator or Android device of some sort. If your server is running on a local Wifi network, use the IP address of your Wifi adapter then replace 127.0.0.1 with that address.

    TLDR; Use you server's IP address instead of 127.0.0.1

    Linux: ifconfig [wlan0]

    Windows: ipconfig

    Edit 2020:

    On newer versions on Android, all HTTP traffic must be encrypted, otherwise the android framework will throw an error. Therefore it's advisable to use a tunnelling server like Ngrok - which comes with free SSL - when testing on your local server.

    0 讨论(0)
  • 2021-01-06 07:11

    Check your xammp or wamp connection. if the mysql and apache services are not active then start all services and run your application it gave proper output

    0 讨论(0)
  • 2021-01-06 07:12

    if your test on local, try to check an ip address (on window open cmd run ipconfig) then put your ip address again.

    This's an example

    String url = http://127.0.0.1:8080/user <-- error

    String url = "http://172.16.5.240:8080/user <-- worked

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