我新手,在学着写android应用,想使用HTTPClient客户端开源项目来访问网页。
导入了两个httpclient包:commons-codec-1.6.jar和commons-httpclient-3.1.jar
然后在我的代码中
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
在访问网络线程中
HttpClient httpclient = new HttpClient();
GetMethod getMethod = new GetMethod("http://www.csdn.net");
int statusCode = httpclient.executeMethod(getMethod);
System.out.println("response=" + getMethod.getResponseBodyAsString());
getMethod.releaseConnection();
问题:
没想到第一句就不能执行,查看log是说找不到HttpClient这个类。
我在网上查了资料说是HttpClient这个库在ADT升级后本身就包含在google源码中,所以产生了冲突……
我不知道如何解决。
具体出错LOG如下:
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;
导入了两个httpclient包:commons-codec-1.6.jar和commons-httpclient-3.1.jar
然后在我的代码中
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
在访问网络线程中
HttpClient httpclient = new HttpClient();
GetMethod getMethod = new GetMethod("http://www.csdn.net");
int statusCode = httpclient.executeMethod(getMethod);
System.out.println("response=" + getMethod.getResponseBodyAsString());
getMethod.releaseConnection();
问题:
没想到第一句就不能执行,查看log是说找不到HttpClient这个类。
我在网上查了资料说是HttpClient这个库在ADT升级后本身就包含在google源码中,所以产生了冲突……
我不知道如何解决。
具体出错LOG如下:
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;