[原创]在使用SDK 23(6.0)版本后org.apache.http相关的类找不到的解决办法

本文详细介绍了在Android Studio中解决HttpClient导入失败的方法,包括在Android模块中添加特定配置、在Dependency中添加依赖以及手动创建optional.json文件等步骤,亲测有效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考:
 
 
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.cli‌​ent:4.1.2' – AlexAndro Oct 5 '15 at 9:10
 
在Dependency中添加以后, Gradle会自动从server下载所需要的依赖。好神奇。。。似乎是下载到了SDK的目录?

转载于:https://www.cnblogs.com/zzpbuaa/p/5404986.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值