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 Hamza Khan
, 1 year ago
Unable to start activity ComponentInfo{com.hfad.viscosity/com.hfad.viscosity.ProcessData}: android.os.NetworkOnMainThreadException
via Stack Overflow by user5236815
, 1 year ago
Unable to start activity ComponentInfo{com.jbs.evecompanion/com.jbs.evecompanion.oauth_callback}: android.os.NetworkOnMainThreadException
via Stack Overflow by tccpg288
, 7 months ago
Unable to start activity ComponentInfo{com.troychuinard.fanpolls/com.troychuinard.fanpolls.ProfileActivity}: android.os.NetworkOnMainThreadException
via Stack Overflow by Giorgio L
, 1 year ago
Unable to start activity ComponentInfo{com.example.neo.gson/com.example.neo.gson.MainActivity}: android.os.NetworkOnMainThreadException
via Stack Overflow by J.Leo
, 7 months ago
Unable to start activity ComponentInfo{com.example.joshuac.googlevision/com.example.joshuac.googlevision.Result}: android.os.NetworkOnMainThreadException
via Stack Overflow by p. ld
, 2 years ago
Unable to start activity ComponentInfo{com.example.tazeen.classnkk/com.example.tazeen.classnkk.CustomActionActivity}: android.os.NetworkOnMainThreadException
android.os.NetworkOnMainThreadException: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)	at java.net.InetAddress.lookupHostByName(InetAddress.java:436)	at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)	at java.net.InetAddress.getAllByName(InetAddress.java:215)	at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)	at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)	at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)	at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)	at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)	at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)	at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)	at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:114)	at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:245)	at com.hfad.viscosity.ProcessData.onCreate(ProcessData.java:110)	at android.app.Activity.performCreate(Activity.java:6272)	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)