Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

  1. ,
    via Stack Overflow by Razgriz

    Happens when you make a network call on the main UI thread of the Android application which results in a UI freeze until the network call is complete and the response is received. Instead, execute the network calls in the background: use AsyncTask.

  2. ,

    An alternative for just getting rid of the Exception is use StrictMode.ThreadPolicy to force execute on main thread.

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    

Solutions on the web

via Stack Overflow by José
, 2 years ago
via Stack Overflow by George Profenza
, 2 years ago
This exception has no message.
via Stack Overflow by Canvas
, 2 years ago
android.os.NetworkOnMainThreadException: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)	at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:168)	at libcore.io.IoBridge.sendto(IoBridge.java:490)	at java.nio.SocketChannelImpl.writeImpl(SocketChannelImpl.java:391)	at java.nio.SocketChannelImpl.write(SocketChannelImpl.java:349)	at java.nio.PipeImpl$PipeSinkChannel.write(PipeImpl.java:114)	at zmq.Signaler.send(Signaler.java:121)	at zmq.Mailbox.send(Mailbox.java:85)	at zmq.Ctx.sendCommand(Ctx.java:388)	at zmq.ZObject.sendCommand(ZObject.java:362)	at zmq.ZObject.sendPlug(ZObject.java:171)	at zmq.ZObject.sendPlug(ZObject.java:161)	at zmq.Own.launchChild(Own.java:126)	at zmq.SocketBase.addEndpoint(SocketBase.java:550)	at zmq.SocketBase.connect(SocketBase.java:542)	at org.zeromq.ZMQ$Socket.connect(ZMQ.java:1246)	at mia.face.id.zmqtestest.MainActivity$1.onClick(MainActivity.java:34)	at android.view.View.performClick(View.java:4438)	at android.view.View$PerformClick.run(View.java:18422)	at android.os.Handler.handleCallback(Handler.java:733)	at android.os.Handler.dispatchMessage(Handler.java:95)	at android.os.Looper.loop(Looper.java:136)	at android.app.ActivityThread.main(ActivityThread.java:5017)	at java.lang.reflect.Method.invokeNative(Native Method)	at java.lang.reflect.Method.invoke(Method.java:515)	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:813)	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)	at dalvik.system.NativeStart.main(Native Method)