I am a novice, learning to write android applications want to use open source project HTTPClient client to access the web.
Httpclient introduced two packages: commons-codec-1.6.jar and commons-httpclient-3.1.jar
Then in my code
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
Accessing the network threadHttpClient httpclient = new HttpClient ();
GetMethod getMethod = new GetMethod ("http://www.csdn.net");
int statusCode = httpclient.executeMethod (getMethod);
System.out.println ("response =" + getMethod.getResponseBodyAsString ());
getMethod.releaseConnection ();
Question:
I did not expect the first one will not be able to perform, view log is saying can not find HttpClient class.
I checked the information that is HttpClient library after ADT in google upgrade itself contains the source code, so a conflict ......
I do not know how to solve.
Specific error LOG follows:
Could not find class 'org.apache.commons.httpclient.HttpClient', referenced from method com.example.webspider.MainActivity $ 2.run
VFY: unable to resolve new-instance 553 (Lorg / apache / commons / httpclient / HttpClient ;) in Lcom / example / webspider / MainActivity $ 2;
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:

Reply:
Help solve the trouble to know what
Reply:
Anyone?

Reply:
How I could do
I cited in the package
commons-httpclient-3.1.jar
commons-codec-1.6.jar
commons-logging-1.1.1.jar
Reply:
Your code with my same? I have not downloaded HttpClient library commons-logging-1.1.1.jar
My SDK is android4.0.3
Reply:
Andrews not own a HttpClient Well, called DefaultHttpClient, this can use this bar.
I introduced commons-httpclient-3.1.jar before the time, although the compiler through, finally, there was a bunch of confusing questions waiting.
Reply:
HttpClient class comes seeking specific path, import an example of a look.
Org.apache.http.client I found a lot of the inside of the class are not perfect interface
Reply:
org.apache.http.impl.client.DefaultHttpClient
Interface does not have full-commons-httpclient-3.1.jar inside,
If you have a reference to commons-httpclient-3.1.jar, then you can directly use the source code,
Reply:
Found the problem, I downloaded java HttpClient package is developed for the WEB, I went straight back in with the android google's own.
No comments:
Post a Comment