安卓的java.net.UnknownHostException:主机是未解决 [英] Android java.net.UnknownHostException: Host is unresolved

查看:849
本文介绍了安卓的java.net.UnknownHostException:主机是未解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这code不工作:

URL         url   = new URL( xmlPath );
InputSource input = new InputSource( url.openStream() );

所有的时间,导致一个UnknownHostException,即使主机的存在,一直使用相同的code。如果从不同的开发主机(机),并且还从浏览器中点击成功。

all the time, resulting in an UnknownHostException, even when the host exists, has been hit successfully using the same code if from a different development host (machine), and also from a browser.

我可能脱节再次问这个问题时,<一个重复href="http://stackoverflow.com/questions/3293659/android-java-net-unknownhostexception-host-is-unresolved-strategy-question">http://stackoverflow.com/questions/3293659/android-java-net-unknownhostexception-host-is-unresolved-strategy-question.论坛软件也不会允许我对不满意的回答这个问题发表意见(以招揽更多地关注解决方案,我最终找到)。也许我没有足够的人气尚未给予的特权。在此期间,我基本上是重新发布的问题和不同的答案。

I'm probably out of line asking this question again, a repeat of http://stackoverflow.com/questions/3293659/android-java-net-unknownhostexception-host-is-unresolved-strategy-question. The forum software would not allow me to comment on the unsatisfactory answer to that question (in order to solicit more attention to the solution I ultimately found). Perhaps I'm not popular enough yet to be given that privilege. In the meantime, I'm essentially re-posting the question and a different answer.

基本上,我同意,也许在Android设备也很难用在某些情况下DNS,但我试过,例如如何使用SAX解析器anddev.org例子,和它的工作在一台机器我有和没有其他。

Basically, I accept that maybe the Android device has a hard time with DNS under certain circumstances, but I've tried, for example the anddev.org example of how to use the SAX parser, and it worked on one machine I have and not on another.

编辑: 如前所述,我知道工作的答案,将发布它。

As noted, I know a working answer and will post it.

我是)问一个问题(这已经被问和回答失败)和b)回答它那些人的利益,我的回答将是有益的。

I am a) asking a question (that's already been asked and unsuccessfully answered) and b) answering it for the benefit of those for whom my answer will be useful.

推荐答案

答案相当简单:删除,然后重新创建AVD(虚拟设备/仿真器)在Eclipse。它的工作对我来说 - 第一次

The answer is devilishly simple: remove, then re-create your AVD (virtual device/emulator) in Eclipse. It worked for me--first time.

这篇关于安卓的java.net.UnknownHostException:主机是未解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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