Android应用导入Apache包错误解决方法

原来在4.4源码上能编译通过的代码,放到6.0上就编译不通过,有如下错误提示:
ERROR: /home/guochongxin/slam/xxx.java:14: The import org.apache.http.HttpEntity cannot be resolved
ERROR: /home/guochongxin/slam/xxx.java:15: The import org.apache.http.HttpResponse cannot be resolved
ERROR: /home/guochongxin/slam/xxx.java:16: The import org.apache.http.client cannot be resolved
ERROR: /home/guochongxin/slam/xxx.java:17: The import org.apache.http.client cannot be resolved
ERROR: /home/guochongxin/slam/xxx.java:18: The import org.apache.http.client cannot be resolved
ERROR: /home/guochongxin/slam/xxx.java:19: The import org.apache.http.impl cannot be resolved
ERROR: /home/guochongxin/slam/xxx.java:20: The import org.apache.http.message cannot be resolved
ERROR: /home/guochongxin/slam/xxx.java:22: The import org.apache.http.protocol cannot be resolved
ERROR: /home/guochongxin/slam/xxx.java:593: DefaultHttpClient cannot be resolved to a type
解决方法是:
1.修改Android.mk,添加LOCAL_JAVA_LIBRARIES += org.apache.http.legacy
2.修改AndroidManifest.xml,在application节中添加:
 <uses-library android:name="org.apache.http.legacy" android:required="false" />

评论

此博客中的热门博文

I/O映射之I/O端口

通过Netlink检测网线插拔

使用seq_file