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 Shubham
, 9 months ago
This exception has no message.
via Stack Overflow by jos_fzr
, 2 years ago
This exception has no message.
via Stack Overflow by Parveen
, 1 year ago
android.os.NetworkOnMainThreadException: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)	at java.net.InetAddress.lookupHostByName(InetAddress.java:385)	at java.net.InetAddress.getLocalHost(InetAddress.java:365)	at org.apache.logging.log4j.core.util.NetUtils.getLocalHostname(NetUtils.java:47)	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:356)	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:416)	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:146)	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:37)	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:473)	at com.torointl.log4j2xtest.MyActivity.(MyActivity.java:14)	at java.lang.Class.newInstanceImpl(Native Method)	at java.lang.Class.newInstance(Class.java:1208)	at android.app.Instrumentation.newActivity(Instrumentation.java:1061)	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)	at android.app.ActivityThread.access$800(ActivityThread.java:135)	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)	at android.os.Handler.dispatchMessage(Handler.java:102)	at android.os.Looper.loop(Looper.java:136)	at android.app.ActivityThread.main(ActivityThread.java:5017)	at java.lang.reflect.Method.invokeNative(Native Method)	at java.lang.reflect.Method.invoke(Method.java:515)	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)	at dalvik.system.NativeStart.main(Native Method)