这是cmd行
"C:\Progra~2\Android\android-sdk\tools\emulator.exe" -avd Touch -netspeed full -netdelay none -http-proxy localhost:3128 -debug-proxy
当我尝试从模拟器打开google.com时,这是控制台:
server name 'localhost' resolved to 127.0.0.1:3128
proxy_http_setup: creating http proxy service connecting to: localhost:3128
server name 'localhost' resolved to 127.0.0.1:3128
proxy_http_setup: creating HTTP Proxy Service Footer is (len=2):
'
'
http_service_connect: trying to connect to (null)
http_service_connect: using HTTP rewriter
tcp:(null)(880): connecting
tcp:(null)(880): connected to http proxy, sending header
tcp:(null)(880): sending 27 bytes:
>> 43 4f 4e 4e 45 43 54 20 28 6e 75 6c 6c 29 20 48 CONNECT (null) H
>> 54 54 50 2f 31 2e 31 0d 0a 0d 0a TTP/1.1....
tcp:(null)(880): header sent, receiving first answer line
tcp:(null)(880): received 'HTTP/1.0 400 Bad Request'
tcp:(null)(880): connection refused, error=400
http_service_connect: trying to connect to (null)
http_service_connect: using HTTP rewriter
tcp:(null)(888): connecting
以下是Wikitionary示例debug
的例外情况Caused by: java.net.ConnectException: en.wiktionary.org/91.198.174.232:80 - Connection refused
关于我的代理:它是我本地计算机上的squid,并且配置为通过父代理(使用auth)进行路由。这适用于浏览器/ Android SDK加载器/ IntelliJ等,但模拟器网络不起作用。
主要的混淆是
tcp:(null)
有什么建议吗?
答案 0 :(得分:2)
模拟器中存在许多代理支持的记录问题,特别是对于Windows上的最新版本。请参阅此处的错误报告:
有一些建议的解决方法可能有所帮助,例如在网络设置中设置代理而不是整个模拟器。
答案 1 :(得分:1)
我遇到同样的问题(Mac Os X - Android SDK Tools 12)。 这些是来自logcat的日志:
08-04 15:33:41.576:INFO / java.net.Socket(256):www.google.com/209.85.148.104(80):java.net.ConnectException:www.google.com/209.85。 148.104:80 - 拒绝连接
我使用squid作为代理,日志是:
1312464815.525 0 172.16.1.1 TCP_DENIED / 400 1587 CONNECT:0 - NONE / - text / html
似乎有些东西丢失了......
我也注意到模拟器试图在请求中使用我的dns。
答案 2 :(得分:0)
由于您从Android模拟器中引用系统上的localhost,因此您必须使用http://10.0.2.2:8080/
。这是因为android模拟器在虚拟机内部运行,因此,127.0.0.1或localhost将是模拟器自己的环回地址。此外,您不需要放置-netspeed full -netdelay none
,因为默认情况下属性设置为这些值。有关模拟器网络的更多信息,请查看this。
修改强>
根据您的具体情况,将localhost
替换为其他地址。如果是路由器/网关地址,则将其替换为10.0.2.1
。如果它是主机环回接口的特殊别名(即开发计算机上的127.0.0.1),则将其替换为10.0.2.2
。如果它是第一个DNS服务器,则将其替换为10.0.2.3
。如果它是可选的第二,第三和第四DNS服务器,则将其替换为10.0.2.4
/ 10.0.2.5
/ 10.0.2.6
。如果它是模拟设备自己的网络/以太网接口,则将其替换为10.0.2.15
。如果它是模拟设备自己的环回接口,则将其替换为127.0.0.1
。此外,开发计算机上的地址127.0.0.1对应于模拟器自己的环回接口,因此,如果要访问在开发计算机的环回接口上运行的服务,则应使用特殊地址10.0.2.2
。点击here了解详情。