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 Google Groups by Dave Booth, 8 months ago
This exception has no message.
via Stack Overflow by titar
, 2 years ago
via GitHub by outlying
, 1 year ago
This exception has no message.
via GitHub by maulikg
, 2 years ago
via Stack Overflow by Peter Sun
, 2 years ago
via symmetricds by binilbenjamin
, 2 years ago
This exception has no message.
android.os.NetworkOnMainThreadException: 	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)	at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)	at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)	at java.net.InetAddress.getAllByName(InetAddress.java:752)	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 okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)	at com.greenlight.zubie.network.ZubieRetrofit$ZubieCallInterceptor.intercept(ZubieRetrofit.java:1063)	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 retrofit2.OkHttpCall.execute(OkHttpCall.java:174)	at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(RxJavaCallAdapterFactory.java:171)	at rx.Subscriber.setProducer(Subscriber.java:211)	at rx.internal.operators.OperatorMap$MapSubscriber.setProducer(OperatorMap.java:99)	at rx.internal.operators.OperatorMap$MapSubscriber.setProducer(OperatorMap.java:99)	at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:152)	at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:138)	at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)	at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)	at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)	at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)	at rx.Observable.unsafeSubscribe(Observable.java:8666)	at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:250)	at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:147)	at rx.internal.operators.OperatorMap$MapSubscriber.onNext(OperatorMap.java:74)	at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:227)	at rx.android.schedulers.LooperScheduler$ScheduledAction.run(LooperScheduler.java:107)	at android.os.Handler.handleCallback(Handler.java:751)	at android.os.Handler.dispatchMessage(Handler.java:95)	at android.os.Looper.loop(Looper.java:154)	at android.app.ActivityThread.main(ActivityThread.java:6077)	at java.lang.reflect.Method.invoke(Native Method)	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)