java.net.ConnectException:/127.0.0.1:8080的Android模拟器 [英] java.net.ConnectException: /127.0.0.1:8080 an android emulator
问题描述
字符串URL =?http://127.0.0.1:8080/SampleServlet/TestServlet
网址URL =新的URL(con_url);
String url = "http://127.0.0.1:8080/SampleServlet/TestServlet?"; URL url = new URL(con_url);
在Android的emualator运行。但我得到了的ConnectException
02-20 13:05:08.745:ERROR /服务器连接(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仿真设备自身的环回接口。
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.
要获得与Web服务器使用连接到你的机器的 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.
另请参见官方的文档或<一个href=\"http://www.linuxtopia.org/online_books/android/devguide/guide/developing/tools/android_emulator_networkaddresses.html\">this!
这篇关于java.net.ConnectException:/127.0.0.1:8080的Android模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!