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 Abhriya Roy
, 1 year ago
This exception has no message.
via Stack Overflow by user2421523
, 2 years ago
via Stack Overflow by Unknown author, 2 years ago
via Stack Overflow by RaymondTiew
, 2 years ago
via GitHub by NVentimiglia
, 2 years ago
This exception has no message.
via Stack Overflow by Alvin
, 2 years ago
This exception has no message.
android.os.NetworkOnMainThreadException: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)	at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:755)	at com.android.okhttp.okio.Okio$1.write(Okio.java:76)	at com.android.okhttp.okio.AsyncTimeout$1.write(AsyncTimeout.java:155)	at com.android.okhttp.okio.RealBufferedSink.flush(RealBufferedSink.java:221)	at com.android.okhttp.internal.http.HttpConnection.flush(HttpConnection.java:141)	at com.android.okhttp.internal.http.HttpTransport.finishRequest(HttpTransport.java:52)	at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:902)	at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:788)	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:443)	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:388)	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:231)	at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)	at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java)	at com.android.backgroundchooser.Main2Activity.getBitmapFromURL(Main2Activity.java:60)	at com.android.backgroundchooser.Main2Activity$1.onClick(Main2Activity.java:42)	at android.view.View.performClick(View.java:5204)	at android.view.View$PerformClick.run(View.java:21156)	at android.os.Handler.handleCallback(Handler.java:739)	at android.os.Handler.dispatchMessage(Handler.java:95)	at android.os.Looper.loop(Looper.java:148)	at android.app.ActivityThread.main(ActivityThread.java:5466)	at java.lang.reflect.Method.invoke(Native Method)	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)