Android 网络请求失败页面,okHttpClient发起网络请求失败

Android中发送HTTP请求,报错如下

E/AndroidRuntime: FATAL EXCEPTION: main

Process: cn.iyikong.managementterminal, PID: 4447

android.os.NetworkOnMainThreadException

at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1571)

at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:115)

at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)

at java.net.InetAddress.getAllByName(InetAddress.java:1152)

at okhttp3.Dns$Companion$SYSTEM$1.lookup(Dns.kt:48)

at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:160)

at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:125)

at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)

at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:199)

at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:109)

at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:77)

at okhttp3.internal.connection.Transmitter.newExchange$okhttp(Transmitter.kt:162)

at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:35)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)

at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)

at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)

at okhttp3.interna

你可能感兴趣的:(Android,网络请求失败页面)