java.net.UnknownHostException: Unable to resolve host “”: No address associated with hostname and End of input at character 0 of

后端 未结 11 1965
滥情空心
滥情空心 2020-11-27 13:38

I\'ve created an app that loads a question from my web services, and it works fine. But, sometimes it crashes and I do not get the reason why this is happening, especially b

相关标签:
11条回答
  • 2020-11-27 14:10

    I was having the same issue, but with Glide. When I was going to disconnect from wifi and reconnect (just like it was suggested here), I noticed that I was in Airplane mode

    0 讨论(0)
  • 2020-11-27 14:13

    I had the same exception in the simulator (Android Studio on OSX) but connecting to the same URL on the iOS simulator worked fine... Looks like it all stemmed from the fact I'd be running the simulator whilst connected to a personal hotspot for my internet connection and then came back later while connected to wifi and the simulator didn't like the new internet connection for some reason, seems like it thought the old hotspot was the current connection, which was no longer working..

    Closing and relaunching the simulator worked!

    0 讨论(0)
  • 2020-11-27 14:14

    I had the same problem. java.net.UnknownHostException: Unable to resolve host “”...

    I'm running Visual Studio 2019 and Xamarin.

    I also switched back to my WiFi but was on a hot spot.

    I solved this by clean swiping the emulator. Restore to factory settings. Then re-running visual studio xamarin app which wil redeploy your app again to the fresh emulator.

    It worked. I thought I was going to battle for days to solve this. Luckily this post pointed me in the right direction.

    I could not understand how it worked perfectly before and then stopped with no code change.

    This is my code for reference:

    using var response = await httpClient.GetAsync(sb.ToString());
    string apiResponse = await response.Content.ReadAsStringAsync();
    
    0 讨论(0)
  • 2020-11-27 14:16

    I was testing my application with the Android emulator and I solved this by turning off and turning on the Wi-Fi on the Android emulator device! It worked perfectly.

    0 讨论(0)
  • 2020-11-27 14:19

    I had this issue on Android 10,

    Changed targetSdkVersion 29 to targetSdkVersion 28 issue resolved. Not sure what is the actual problem.

    I think not a good practice, but it worked.

    before:

    compileSdkVersion 29

    minSdkVersion 14

    targetSdkVersion 29

    Now:

    compileSdkVersion 29

    minSdkVersion 14

    targetSdkVersion 28

    0 讨论(0)
  • 2020-11-27 14:23

    I encountered this problem too, reconnecting the WiFi can solve this.

    For us ,we can check if the phone can resolve the host to IP when we start application. If it cannot resolve, tell the user to check the WiFi and then exit.

    I hope it helps.

    0 讨论(0)
提交回复
热议问题