java.lang.RuntimeException

Unable to start activity ComponentInfo{com.example.neo.gson/com.example.neo.gson.MainActivity}: android.os.NetworkOnMainThreadException

Solutions on the web37457

  • Unable to start activity ComponentInfo{com.example.neo.gson/com.example.neo.gson.MainActivity}: android.os.NetworkOnMainThreadException
  • Unable to start activity ComponentInfo{SignUp}: android.os.NetworkOnMainThreadException
  • via GitHub by sergiocastell
    , 8 months ago
    Unable to start activity ComponentInfo{rom.stalker/browser.afh.MainActivity}: android.os.NetworkOnMainThreadException
  • Stack trace

    • java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.neo.gson/com.example.neo.gson.MainActivity}: android.os.NetworkOnMainThreadException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494) at android.app.ActivityThread.access$900(ActivityThread.java:157) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5525) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) Caused by: 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.getResponse(HttpURLConnectionImpl.java:384) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:231) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java) at com.example.neo.gson.MainActivity.onCreate(MainActivity.java:47) at android.app.Activity.performCreate(Activity.java:6272) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    2 times, 1 year ago
    Once, 1 year ago
    Unknown user
    Once, 1 year ago
    Unknown user
    Once, 1 year ago
    5 times, 1 month ago
    38 more bugmates