在用Android测试JSON数据解析的时候,报了这样一个异常:

java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused

Android程序报错 Connection refused 处理

原来模拟器默认把localhost或者127.0.0.1当做本身了

在网上查了下,在模拟器上可以用10.0.2.2代替127.0.0.1和localhost
另外如果是在局域网环境可以用 192.168.0.x或者192.168.1.x(根据具体配置)连接本机

 

修改后结果:

Android程序报错 Connection refused 处理

 

相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2021-04-08
猜你喜欢
  • 2021-06-26
  • 2021-12-12
  • 2021-10-21
  • 2021-10-06
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
相关资源
相似解决方案