Android java.net.UnknownHostException: Host is unresolved

前端 未结 17 1008
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 08:43

This code doesn\'t work:

URL         url   = new URL( xmlPath );
InputSource input = new InputSource( url.openStream() );

all the time, res

相关标签:
17条回答
  • 2020-12-01 09:34

    issue resolved

    run cd C:\Program Files\Android\android-sdk\tools

    run android list avd in cmd returns list of ur availabe avd.... in my case its Myabc_avd

    run emulator @Myabc_avd -dns-server 8.8.8.8 in cmd ...avd will show avd go to avd's browser and type www.google.com will show google page. u can now access browser using hostname like myfrstapp.com

    if all go well then u can run ur project using eclipse but make sure it is running in avd which is running from cmd.

    0 讨论(0)
  • 2020-12-01 09:38

    In my case i have just restarted the Emulator and it worked.

    0 讨论(0)
  • 2020-12-01 09:41

    In my case I was using host name based URL with HttpURLConnection. However, using an IP based url, resolved the issue. I also deleted/recreated the AVD but that didn't help.

    0 讨论(0)
  • 2020-12-01 09:45

    It's so simple. No need of Restart eclipse OR delete and creating Emulator, you just need to follow the steps given below:

    1. Right Click on your project
    2. Click "Run as"
    3. Click "Run configuration"
    4. Window will get opened
    5. In left panel select your project run configuration
    6. Then in right panel open "Target" tab
    7. Scroll down
    8. You will get an option at bottom called "Additional Emulator Command Line Arguments"
    9. Put "-dns-server 8.8.8.8" these values (without double quotes) in text box.

    That's it...

    0 讨论(0)
  • 2020-12-01 09:48

    My problem was when sharing the internet from the computer via WIFI, after ethernet connection was lost and reconnected I couldn't achieve connection on the phone. This was fixed by restarting internet sharing on computer.

    Hope it helps someone.

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