티스토리 뷰

Computer/Android

[Android] conn.getResponseCode()에서 에러

인생이글케쉬우냐 2013. 10. 2. 11:51

안드로이드에서 웹을 접속해 띄워보려고 하는데,

잘 돌아가다가 conn.getResponseCode()에서 에러가 났다.

e.printStackTrace()를 catch부분에 두고 찍어보니

10-02 02:24:40.170: W/System.err(699): java.net.UnknownHostException: Unable to resolve host "m.emart.com": No address associated with hostname
10-02 02:24:40.180: W/System.err(699): 	at java.net.InetAddress.lookupHostByName(InetAddress.java:426)
10-02 02:24:40.190: W/System.err(699): 	at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
10-02 02:24:40.200: W/System.err(699): 	at java.net.InetAddress.getAllByName(InetAddress.java:220)
10-02 02:24:40.211: W/System.err(699): 	at libcore.net.http.HttpConnection.(HttpConnection.java:71)
10-02 02:24:40.220: W/System.err(699): 	at libcore.net.http.HttpConnection.(HttpConnection.java:50)
10-02 02:24:40.220: W/System.err(699): 	at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
10-02 02:24:40.230: W/System.err(699): 	at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
10-02 02:24:40.230: W/System.err(699): 	at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
10-02 02:24:40.240: W/System.err(699): 	at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
10-02 02:24:40.250: W/System.err(699): 	at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
10-02 02:24:40.250: W/System.err(699): 	at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
10-02 02:24:40.261: W/System.err(699): 	at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
10-02 02:24:40.270: W/System.err(699): 	at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
10-02 02:24:40.280: W/System.err(699): 	at libcore.net.http.HttpURLConnectionImpl.getErrorStream(HttpURLConnectionImpl.java:100)
10-02 02:24:40.291: W/System.err(699): 	at kr.co.zadusoft.h2webtest.MainActivity$ConnectThread.request(MainActivity.java:84)
10-02 02:24:40.301: W/System.err(699): 	at kr.co.zadusoft.h2webtest.MainActivity$ConnectThread.run(MainActivity.java:59)
10-02 02:24:40.310: W/System.err(699): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
10-02 02:24:40.330: W/System.err(699): 	at libcore.io.Posix.getaddrinfo(Native Method)
10-02 02:24:40.330: W/System.err(699): 	at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
10-02 02:24:40.360: W/System.err(699): 	at java.net.InetAddress.lookupHostByName(InetAddress.java:411)
10-02 02:24:40.360: W/System.err(699): 	... 15 more

인터넷사용권한을 줘야 한다고 되어있어서

나름 그 권한 설정을 한다는게 application 태그 밑에 두었던 것이 문제였다.

(/AndroidManifest.xml 에서 users-permission)





    

           
            
    
        
            
                

                
            
        
    


위에처럼 uses-sdk 밑에 uses-permission을 주고 나서야 정상적으로 작동이 되었다.



반응형