Under a httpclient-4.1.1.jar, wrote a very simple example, but run up the error, you see, this is why it?
HttpResponse response = null;
DefaultHttpClient httpclient = new DefaultHttpClient ();
/ / HttpPost httppost = new HttpPost ("http://www.baidu.com");
HttpGet httpget = new HttpGet ("http://www.baidu.com/");
try {
response = httpclient.execute (httpget);
} Catch (ClientProtocolException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
} Catch (IOException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
Reported the following error
05-04 02:01:03.005: WARN / System.err (361): java.net.UnknownHostException: www.baidu.com
05-04 02:01:03.015: WARN / System.err (361): at java.net.InetAddress.lookupHostByName (InetAddress.java: 513)
05-04 02:01:03.015: WARN / System.err (361): at java.net.InetAddress.getAllByNameImpl (InetAddress.java: 278)
05-04 02:01:03.025: WARN / System.err (361): at java.net.InetAddress.getAllByName (InetAddress.java: 242)
05-04 02:01:03.034: WARN / System.err (361): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection (DefaultClientConnectionOperator.java: 136)
05-04 02:01:03.034: WARN / System.err (361): at org.apache.http.impl.conn.AbstractPoolEntry.open (AbstractPoolEntry.java: 164)
05-04 02:01:03.034: WARN / System.err (361): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open (AbstractPooledConnAdapter.java: 119)
05-04 02:01:03.054: WARN / System.err (361): at org.apache.http.impl.client.DefaultRequestDirector.execute (DefaultRequestDirector.java: 348)
05-04 02:01:03.054: WARN / System.err (361): at org.apache.http.impl.client.AbstractHttpClient.execute (AbstractHttpClient.java: 555)
05-04 02:01:03.065: WARN / System.err (361): at org.apache.http.impl.client.AbstractHttpClient.execute (AbstractHttpClient.java: 487)
05-04 02:01:03.065: WARN / System.err (361): at org.apache.http.impl.client.AbstractHttpClient.execute (AbstractHttpClient.java: 465)
05-04 02:01:03.074: WARN / System.err (361): at com.http.test.main.onCreate (main.java: 26)
05-04 02:01:03.074: WARN / System.err (361): at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java: 1047)
05-04 02:01:03.074: WARN / System.err (361): at android.app.ActivityThread.performLaunchActivity (ActivityThread.java: 2627)
05-04 02:01:03.084: WARN / System.err (361): at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java: 2679)
05-04 02:01:03.094: WARN / System.err (361): at android.app.ActivityThread.access $ 2300 (ActivityThread.java: 125)
05-04 02:01:03.094: WARN / System.err (361): at android.app.ActivityThread $ H.handleMessage (ActivityThread.java: 2033)
05-04 02:01:03.094: WARN / System.err (361): at android.os.Handler.dispatchMessage (Handler.java: 99)
05-04 02:01:03.104: WARN / System.err (361): at android.os.Looper.loop (Looper.java: 123)
05-04 02:01:03.104: WARN / System.err (361): at android.app.ActivityThread.main (ActivityThread.java: 4627)
05-04 02:01:03.104: WARN / System.err (361): at java.lang.reflect.Method.invokeNative (Native Method)
05-04 02:01:03.115: WARN / System.err (361): at java.lang.reflect.Method.invoke (Method.java: 521)
05-04 02:01:03.115: WARN / System.err (361): at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java: 868)
05-04 02:01:03.125: WARN / System.err (361): at com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 626)
05-04 02:01:03.125: WARN / System.err (361): at dalvik.system.NativeStart.main (Native Method)
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
You are not networked through a proxy?
Try real machine
Reply:
Try your normal operating environment the Internet? Baidu down with their own browser.
Reply:
Useless agent
Simulator 2 machines have been tried on, are so
Browser emulator can be normal
Reply:
Just try a real machine, reported the same mistakes
Reply:
Pumping his own look. .
Forget the authority. .
Depressed. . Wasted several hours, a stupid mistake. .
Reply:
I would also like nausea simulator comparison without prompting
Reply:
Yeah me too. Also make this mistake.
Reply:
Haha, the same error ......, thank you
Reply:
I android2.2 added
This error was reported. . Dizzy in. .
Reply:
Thank success
Reply:
Nausea mistake two days, finally solved ...... top lz
Reply:
Thank ah, if you did not see this post, I do not know how long you want to tune
Reply:
http://blog.csdn.net/w250shini11/article/details/8646859
In the android development time often encounter this error, in general, the most common cause of this error, there are two cases:
1.android not open device network connection, such as 3G network and WIFI network
So, if you encounter this error, please check whether the network is properly connected.
2.Manifest document does not indicate network access
/ / Network access
Reply:
Check the 2:00:
1,
2, whether the target device is connected to the network: for example, WiFi or the mobile network.
No comments:
Post a Comment