Mensaje de error ‘java.net.SocketException: socket failed: EACCES (Permiso denegado)’

Recibo el mensaje de error

java.net.SocketException: socket failed: EACCES (Permiso denegado)

cuando trato de aplicar el código a continuación. Esta es la función que llamo y me da esta excepción.

public void run() { // TODO Auto-generated method stub URL myurl = null; try { myurl = new URL("http://10.0.2.2/list.JSON"); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { URLConnection myconn = myurl.openConnection(); InputStream in = new BufferedInputStream(myconn.getInputStream()); InputStreamReader reader = new InputStreamReader(in); BufferedReader br = new BufferedReader(reader); String line; StringBuilder sb = new StringBuilder(); while ((line=br.readLine()) != null) { sb.append(line); //Toast.makeText(getApplicationContext(), "I enter here", Toast.LENGTH_LONG).show(); } jsoncode = sb.toString(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } threading = true; super.run(); } 

LogCat :

 06-30 11:33:21.457: W/System.err(619): java.net.SocketException: socket failed: EACCES (Permission denied) 06-30 11:33:21.467: W/System.err(619): at libcore.io.IoBridge.socket(IoBridge.java:573) 06-30 11:33:21.467: W/System.err(619): at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201) 06-30 11:33:21.479: W/System.err(619): at java.net.Socket.checkOpenAndCreate(Socket.java:663) 06-30 11:33:21.479: W/System.err(619): at java.net.Socket.connect(Socket.java:807) 06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnection.(HttpConnection.java:77) 06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnection.(HttpConnection.java:50) 06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351) 06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86) 06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 06-30 11:33:21.487: W/System.err(619): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308) 06-30 11:33:21.487: W/System.err(619): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303) 06-30 11:33:21.497: W/System.err(619): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282) 06-30 11:33:21.497: W/System.err(619): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232) 06-30 11:33:21.497: W/System.err(619): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273) 06-30 11:33:21.497: W/System.err(619): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168) 06-30 11:33:21.497: W/System.err(619): at com.apk.PItestActivity$connection.run(PItestActivity.java:190) 06-30 11:33:21.507: W/System.err(619): Caused by: libcore.io.ErrnoException: socket failed: EACCES (Permission denied) 06-30 11:33:21.517: W/System.err(619): at libcore.io.Posix.socket(Native Method) 06-30 11:33:21.517: W/System.err(619): at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:169) 06-30 11:33:21.527: W/System.err(619): at libcore.io.IoBridge.socket(IoBridge.java:558) 06-30 11:33:21.527: W/System.err(619): ... 15 more 

Y este es mi archivo manifiesto:

                  

¿Como puedo solucionar este problema?

Prueba con,

  

en lugar de,

  

Prueba esto:

  

Y sus activity names deben ser así con capital letters :

     

intentalo.

    

Intente mover fuera de la etiqueta .

Agregue esos códigos fuente a su archivo Java de la siguiente manera:

 StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build()); 

Es posible que necesites hacer AndroidStudio – Build – Clean

Si actualizó el manifiesto a través del sistema de archivos o Git, no recogerá los cambios.