java.net.ConnectException:/127.0.0.1:8080 一个安卓模拟器 [英] java.net.ConnectException: /127.0.0.1:8080 an android emulator

查看:19
本文介绍了java.net.ConnectException:/127.0.0.1:8080 一个安卓模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

String url = "http://127.0.0.1:8080/SampleServlet/TestServlet?";URL url = 新 URL(con_url);

String url = "http://127.0.0.1:8080/SampleServlet/TestServlet?"; URL url = new URL(con_url);

在安卓模拟器中运行.但我得到了连接异常02-20 13:05:08.745: 错误/服务器连接 (230): java.net.ConnectException:/127.0.0.1:8080 - 连接被拒绝

run in android emualator. but i got the connectexception 02-20 13:05:08.745: ERROR/Server Connection(230): java.net.ConnectException: /127.0.0.1:8080 - Connection refused

请回复我

谢谢

推荐答案

127.0.0.1是Android仿真设备自带的loopback接口.

127.0.0.1 is a Android emulated device's own loopback interface.

换句话说,您使用 127.0.0.1 连接到 android 模拟设备(而不是您的计算机).

In other words, you connect to android emulated device (not to your computer) by using 127.0.0.1.

要通过网络服务器连接到您的机器,请使用 10.0.2.2 或真实机器 IP 地址(如果您可以从网络直接访问).

To get connection to your machine with web-server use 10.0.2.2 or real machine IP address (if you have direct access from web).

使用命令 ipconfig(Windows)/ifconfig(Linux) 获取您的 IP 地址.

Use command ipconfig(Windows)/ifconfig(Linux) to obtain your IP address.

另请参阅官方文档这个

这篇关于java.net.ConnectException:/127.0.0.1:8080 一个安卓模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆