Android java.net.UnknownHostException:无法解析主机;谷歌网站“;
我正在Galaxy选项卡(v1)上运行我的应用程序。Android java.net.UnknownHostException:无法解析主机;谷歌网站“;,android,unknown-host,Android,Unknown Host,我正在Galaxy选项卡(v1)上运行我的应用程序。 我添加了 <uses-permission android:name="android.permission.INTERNET"></uses-permission> 我运行它,它抛出异常: 01-05 19:15:04.007: W/System.err(3303): java.net.UnknownHostException: Unable to resolve host "google.com": No add
我添加了
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
我运行它,它抛出异常:
01-05 19:15:04.007: W/System.err(3303): java.net.UnknownHostException: Unable to resolve host "google.com": No address associated with hostname
01-05 19:15:04.007: W/System.err(3303): at java.net.InetAddress.lookupHostByName(InetAddress.java:426)
01-05 19:15:04.007: W/System.err(3303): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
01-05 19:15:04.007: W/System.err(3303): at java.net.InetAddress.getByName(InetAddress.java:295)
01-05 19:15:04.007: W/System.err(3303): at com.sonyericsson.extras.liveview.plugins.sandbox.SandboxPluginService$2.run(SandboxPluginService.java:184)
01-05 19:15:04.007: W/System.err(3303): at java.lang.Thread.run(Thread.java:856)
01-05 19:15:04.007: W/System.err(3303): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
01-05 19:15:04.011: W/System.err(3303): at libcore.io.Posix.getaddrinfo(Native Method)
01-05 19:15:04.011: W/System.err(3303): at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
01-05 19:15:04.011: W/System.err(3303): at java.net.InetAddress.lookupHostByName(InetAddress.java:411)
01-05 19:15:04.011: W/System.err(3303): ... 4 more
你试过使用google.com而不仅仅是google.com吗
正如@SLaks所说,您的方法是错误的,因为您在启动线程后返回,需要使用回调(类似于您在iOS中对代理所做的操作)。您的方法从根本上被破坏了;您将在线程运行之前返回该值。如果你等待线程,你会冻结你的应用程序,这正是你应该避免的。你需要使用回调或承诺。我会在它运行之前返回它吗?I
.start()
将其关闭,然后在关闭后返回no。你.start()
,然后立即返回。还有其他人也有类似的问题;
01-05 19:15:04.007: W/System.err(3303): java.net.UnknownHostException: Unable to resolve host "google.com": No address associated with hostname
01-05 19:15:04.007: W/System.err(3303): at java.net.InetAddress.lookupHostByName(InetAddress.java:426)
01-05 19:15:04.007: W/System.err(3303): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
01-05 19:15:04.007: W/System.err(3303): at java.net.InetAddress.getByName(InetAddress.java:295)
01-05 19:15:04.007: W/System.err(3303): at com.sonyericsson.extras.liveview.plugins.sandbox.SandboxPluginService$2.run(SandboxPluginService.java:184)
01-05 19:15:04.007: W/System.err(3303): at java.lang.Thread.run(Thread.java:856)
01-05 19:15:04.007: W/System.err(3303): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
01-05 19:15:04.011: W/System.err(3303): at libcore.io.Posix.getaddrinfo(Native Method)
01-05 19:15:04.011: W/System.err(3303): at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
01-05 19:15:04.011: W/System.err(3303): at java.net.InetAddress.lookupHostByName(InetAddress.java:411)
01-05 19:15:04.011: W/System.err(3303): ... 4 more