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 TheNerdFromYesterday
, 2 years ago
This exception has no message.
via Stack Overflow by Tejas Desai
, 2 years ago
via Stack Overflow by arya maharta
, 2 years ago
via Stack Overflow by MRefaat
, 2 years ago
android.os.NetworkOnMainThreadException: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)	at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:163)	at libcore.io.IoBridge.recvfrom(IoBridge.java:506)	at java.net.PlainSocketImpl.read(PlainSocketImpl.java:489)	at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)	at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:241)	at java.io.InputStream.read(InputStream.java:162)	at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)	at java.io.BufferedInputStream.read(BufferedInputStream.java:227)	at com.android.okhttp.internal.Util.readAsciiLine(Util.java:316)	at com.android.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:324)	at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:135)	at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:644)	at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:347)	at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)	at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:503)	at com.kingouser.com.f.l.b(Unknown Source)	at com.kingouser.com.service.b.onReceive(Unknown Source)	at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:768)	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:5102)	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:785)	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)