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 mpcom00
, 1 year ago
This exception has no message.
via Stack Overflow by cmnl
, 2 years ago
This exception has no message.
via Stack Overflow by user3579259
, 2 years ago
This exception has no message.
via Stack Overflow by DZhuk
, 2 years ago
This exception has no message.
via GitHub by junjunfly
, 9 months ago
android.os.NetworkOnMainThreadException: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)	at java.net.InetAddress.lookupHostByName(InetAddress.java:418)	at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)	at java.net.InetAddress.getAllByName(InetAddress.java:215)	at okhttp3.Dns$1.lookup(Dns.java:39)	at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:172)	at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.java:138)	at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:80)	at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:178)	at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)	at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)	at com.pokegoapi.auth.PtcCredentialProvider$2.intercept(PtcCredentialProvider.java:95)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)	at okhttp3.RealCall.execute(RealCall.java:60)	at com.pokegoapi.auth.PtcCredentialProvider.login(PtcCredentialProvider.java:120)	at com.pokegoapi.auth.PtcCredentialProvider.(PtcCredentialProvider.java:101)	at com.pokegoapi.examples.CatchPokemonAtAreaExample.main(CatchPokemonAtAreaExample.java:62)	at com.example.mpcom.testapi30.MainActivity$1.onClick(MainActivity.java:33)	at android.view.View.performClick(View.java:5197)	at android.view.View$PerformClick.run(View.java:20926)	at android.os.Handler.handleCallback(Handler.java:739)	at android.os.Handler.dispatchMessage(Handler.java:95)	at android.os.Looper.loop(Looper.java:145)	at android.app.ActivityThread.main(ActivityThread.java:5951)	at java.lang.reflect.Method.invoke(Native Method)	at java.lang.reflect.Method.invoke(Method.java:372)	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)