android.os.NetworkOnMainThreadException: This exception has no message.

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

,
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.

,

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
, 11 months ago
This exception has no message.
via Google Groups by 金泰斗, 6 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 com.android.org.conscrypt.Platform.blockGuardOnNetwork(Platform.java:300)
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)

Users with the same issue

Once, 1 month ago
3 times, 6 months ago
6 times, 9 months ago
34 times, 10 months ago
4 times, 11 months ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.