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 GitHub by DavidEdwards
, 1 year ago
This exception has no message.
via Google Groups by 金泰斗, 10 months ago
via Stack Overflow by Luca S.
, 1 year ago
via Stack Overflow by Abdullah Umer
, 2 years ago
This exception has no message.
via Stack Overflow by Mohd Riaz
, 2 years ago
This exception has no message.
android.os.NetworkOnMainThreadException: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)	at com.android.org.conscrypt.Platform.blockGuardOnNetwork(Platform.java:300)	at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:808)	at okio.Okio$1.write(SourceFile:78)	at okio.AsyncTimeout$1.write(SourceFile:179)	at okio.RealBufferedSink.flush(SourceFile:216)	at okhttp3.internal.http2.Http2Writer.flush(SourceFile:121)	at okhttp3.internal.http2.Http2Connection.newStream(SourceFile:239)	at okhttp3.internal.http2.Http2Connection.newStream(SourceFile:205)	at okhttp3.internal.http2.Http2Codec.writeRequestHeaders(SourceFile:105)	at okhttp3.internal.http.CallServerInterceptor.intercept(SourceFile:43)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:67)	at dae.evepi.network.LoggingInterceptor.intercept(SourceFile:20)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)	at okhttp3.internal.connection.ConnectInterceptor.intercept(SourceFile:45)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:67)	at okhttp3.internal.cache.CacheInterceptor.intercept(SourceFile:93)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:67)	at okhttp3.internal.http.BridgeInterceptor.intercept(SourceFile:93)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(SourceFile:120)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:67)	at okhttp3.RealCall.b(SourceFile:179)	at okhttp3.RealCall.execute(SourceFile:63)	at dae.evepi.network.Api.a(SourceFile:188)	at dae.evepi.network.Api.getPlanetLayoutBlocking(SourceFile:713)	at dae.evepi.network.Api$7.run(SourceFile:753)	at java.lang.Thread.run(Thread.java:761)