Android异常-UnKnownHostException-Unable to reslove host "XXX" no address associated
2016-12-19 22:48
661 查看
异常环境:
模拟机上跑程序,之前正常,然后某一次之后就开始报这个错误异常出现的地方:
URL url = new URL(netUrl); //返回一个URLConnection对象,它表示到URL所引用的远程对象的连接 conn = (HttpURLConnection) url.openConnection(); //设置连接超时为5秒 conn.setConnectTimeout(5000); //建立到远程对象的实际连接 conn.connect(); //得到连接读取的输入流 inputStream = conn.getInputStream();
异常解决方法:
1.检查是否连接网络
这个因为是模拟机,直接看电脑有没有正常的连接网络是最快捷的检验方法2.检查Android.manifest.xml文件是否配置网络权限
<!--允许应用程序联网,以便向我们的服务器端发送数据--> <uses-permission android:name="android.permission.INTERNET"/>
3.如果以上两个方法都不起作用,请重启你的模拟机试一下,说不定就有奇迹发生了.
姐姐我在这个bug上纠结了两个小时有木有,如果不是感觉有点太夸张,都差点修改host文件,配置dns了.参考博客:
http://blog.csdn.net/murongshusheng/article/details/7623188http://stackoverflow.com/questions/3514398/android-java-net-unknownhostexception-host-is-unresolved
相关文章推荐
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- 解决android上java.net.UnknownHostException: Unable to resolve host "xxxx": No address associated wit
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- android java.net.UnknownHostException: Unable to resolve host "...": No address associated 错误
- java.net.UnknownHostException: Unable to resolve host "api1.51zhenghao.cn": No address associated wi
- java.net.UnknownHostException: Unable to resolve host "images.liqucn.com": No address associated wit
- UniversalAndroidImageLoader出现异常:ImageLoader: Unable to resolve host "https": No address associated with host
- Android异常:Unable to resolve host "...": No address associated 错误 解决方案
- java.net.UnknownHostException: Unable to resolve host "api1.51zhenghao.cn": No address associated w
- java.net.UnknownHostException: Unable to resolve host "api102.meishi.cc": No address associated with hostname
- java.net.UnknownHostException: Unable to resolve host "stats.umsns.com": No address associated with
- java.net.UnknownHostException: Unable to resolve host "xxx": No address associated with hostname
- Unable to resolve host "stats.umsns.com": No address associated with hostname: [Caught Exception in
- Android 关于Unable to resolve host "...": No address associated服务器返回错误
- Android 异常java.net.UnknownHostException: Unable to resolve host xxx: No address associate