android应用程序在重新启动java.net时崩溃.未知主机异常:无法解析主机



当我重新启动我的设备时,它会崩溃我的应用程序,很难调试,我搜索的内容我说它说要添加我在清单中的互联网权限我不知道该怎么办,有人能指导我吗?

02-24 17:37:05.750: I/System.out(5201): onErrorResponse:com.android.volley.NoConnectionError: java.net.UnknownHostException: Unable to resolve host "eventiapp.com": No address associated with hostname
    02-24 17:37:05.750: W/System.err(5201): com.android.volley.NoConnectionError: java.net.UnknownHostException: Unable to resolve host "eventiapp.com": No address associated with hostname
    02-24 17:37:05.750: W/System.err(5201):     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:133)
    02-24 17:37:05.750: W/System.err(5201):     at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:105)
    02-24 17:37:05.750: W/System.err(5201): Caused by: java.net.UnknownHostException: Unable to resolve host "eventiapp.com": No address associated with hostname
    02-24 17:37:05.755: W/System.err(5201):     at java.net.InetAddress.lookupHostByName(InetAddress.java:424)
    02-24 17:37:05.755: W/System.err(5201):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
    02-24 17:37:05.755: W/System.err(5201):     at java.net.InetAddress.getAllByName(InetAddress.java:214)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
    02-24 17:37:05.755: W/System.err(5201):     at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:188)
    02-24 17:37:05.755: W/System.err(5201):     at com.android.volley.toolbox.HurlStack.addBodyIfExists(HurlStack.java:227)
    02-24 17:37:05.755: W/System.err(5201):     at com.android.volley.toolbox.HurlStack.setConnectionParametersForRequest(HurlStack.java:210)
    02-24 17:37:05.755: W/System.err(5201):     at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:106)
    02-24 17:37:05.755: W/System.err(5201):     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)
    02-24 17:37:05.755: W/System.err(5201):     ... 1 more
    02-24 17:37:05.755: W/System.err(5201): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
    02-24 17:37:05.760: W/System.err(5201):     at libcore.io.Posix.getaddrinfo(Native Method)
    02-24 17:37:05.770: W/System.err(5201):     at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
    02-24 17:37:05.770: W/System.err(5201):     at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
    02-24 17:37:05.770: W/System.err(5201):     ... 18 more
    02-24 17:37:05.770: W/System.err(5201): Caused by: libcore.io.ErrnoException: getaddrinfo failed: ENETUNREACH (Network is unreachable)
    02-24 17:37:05.775: W/System.err(5201):     ... 21 more##

在创建http请求之前是否检查网络连接,如下所示:

ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnectedOrConnecting();

相关内容

  • 没有找到相关文章

最新更新