参考:
http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio
http://www.zhihu.com/question/35597452/answer/63619567
1. 在Android模块里面添加
android {
useLibrary ‘org.apache.http.legacy‘
}
这个对我不起作用,依然提示 不识别 org.apache.http.legacy
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的目录?