美文网首页我爱编程
Android应用导入Apache包错误解决方法

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

作者: 网路元素 | 来源:发表于2017-09-10 10:50 被阅读167次

原来在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" />

相关文章

网友评论

    本文标题:Android应用导入Apache包错误解决方法

    本文链接:https://www.haomeiwen.com/subject/qrpzjxtx.html