:java.net.UnknownHostException:无法解析主机“hosturl”:没有与主机名关联的地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13337899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
: java.net.UnknownHostException: Unable to resolve host "hosturl": No address associated with hostname
提问by KItis
I have android application which connect to "hosturl"
over the web. This application can connect to hosturl
in the initial steps, but after i try to test it for some time(say 20 or more requests), I get above exception and I can not no longer connect to above url.
我有"hosturl"
通过网络连接到的 android 应用程序。此应用程序可以hosturl
在初始步骤中连接到,但是在我尝试对其进行测试一段时间后(例如 20 个或更多请求),我遇到了上述异常并且无法再连接到上述 url。
If i restart my android handset, then application can again connect to the "hosturl"
but again I get the exception after I have tried to connect to hosturl
few number of times
如果我重新启动我的 android 手机,那么应用程序可以再次连接到,"hosturl"
但在我尝试连接hosturl
几次后再次出现异常
Could anybody help me here If you have encounter such a behavior with an android application before.
如果您之前在 android 应用程序中遇到过这种行为,有人可以在这里帮助我。
回答by Siddesh Sahu
You probably don't have the INTERNET permission. Try adding this to your AndroidManifest.xml file, right before </manifest>
:
您可能没有 INTERNET 权限。尝试将其添加到您的 AndroidManifest.xml 文件中,就在之前</manifest>
:
<uses-permission android:name="android.permission.INTERNET" />
回答by Eslam Amgad
I met this and I just closed my AVD and start it again and it worked...
我遇到了这个,我刚刚关闭了我的 AVD 并重新启动它,它起作用了......
回答by luttu android
Check your Internet connection. Check Wifi. Check Server.
检查您的互联网连接。检查无线网络。检查服务器。