[原创]在使用SDK 23(6.0)版本后org.apache.http相关的类找不到的解决办法
2016-04-18 16:38
633 查看
参考:
http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio
http://www.zhihu.com/question/35597452/answer/63619567
http://stackoverflow.com/questions/33898857/why-warningunable-to-find-optional-library-org-apache-http-legacy-occurs
1. 在Android模块里面添加
android {
useLibrary 'org.apache.http.legacy'
}
这个对我不起作用,依然提示 不识别 org.apache.http.legacy
更新:发现在 SDK/platforms/android-23/optional 下面其实是有org.apache.http.legacy这个文件的。在这个目录下新建 optional.json, 内容如下:
==========
[ { "name": "org.apache.http.legacy", "jar": "org.apache.http.legacy.jar", "manifest": false } ]
===========
然后这个方法生效。(谁动了我的optional.json ?!)
2. 在Dependency中添加:
dependencies {
compile 'org.apache.httpcomponents:httpcore:4.4.2'
}
这个亲测有效!! ^_^
3. 在Dependency中添加:
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
没有测试,估计有效。看别人的回复:
You can simply add this to Gradle dependencies:
========================
This helps. But still not enough if you want to use other classes like
在Dependency中添加以后, Gradle会自动从server下载所需要的依赖。好神奇。。。似乎是下载到了SDK的目录?
http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio
http://www.zhihu.com/question/35597452/answer/63619567
http://stackoverflow.com/questions/33898857/why-warningunable-to-find-optional-library-org-apache-http-legacy-occurs
1. 在Android模块里面添加
android {
useLibrary 'org.apache.http.legacy'
}
这个对我不起作用,依然提示 不识别 org.apache.http.legacy
更新:发现在 SDK/platforms/android-23/optional 下面其实是有org.apache.http.legacy这个文件的。在这个目录下新建 optional.json, 内容如下:
==========
[ { "name": "org.apache.http.legacy", "jar": "org.apache.http.legacy.jar", "manifest": false } ]
===========
然后这个方法生效。(谁动了我的optional.json ?!)
2. 在Dependency中添加:
dependencies {
compile 'org.apache.httpcomponents:httpcore:4.4.2'
}
这个亲测有效!! ^_^
3. 在Dependency中添加:
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
没有测试,估计有效。看别人的回复:
You can simply add this to Gradle dependencies:
compile "org.apache.httpcomponents:httpcore:4.3.2"
========================
This helps. But still not enough if you want to use other classes like
HttpGet. For that I used
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'– AlexAndro Oct 5 '15 at 9:10
在Dependency中添加以后, Gradle会自动从server下载所需要的依赖。好神奇。。。似乎是下载到了SDK的目录?
相关文章推荐
- 网络封包分析工具Charles
- 网络:HTTP 状态码
- 2016-04-20 for http协议
- 王高利:TCP/IP 端口号大全
- UNP(一):网络编程角度下的TCP、UDP协议
- HTTP响应头和请求头信息对照表
- 深入理解CNN的细节
- http://netfilter.org/ 读后感
- 网络中出现TCP、UDP粘包、分包的两点解决办法
- TCP 可靠性
- Retrofit2源码分析
- SUSE学习(网络配置)
- TCP协议的学习(六)滑动窗口 停止等待 退后N帧 选择重传
- 未配置TCP/IP,必须安装并启用网络适配器
- HttpServletResponse,HttpServletRequest详解
- TCP加速–dpdk实践
- JSP报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- 网络请求错误
- xampp httpd-vhosts.conf 配置
- Mac下通过Wireshark和rvictl网络监听iPhone应用