Android studio中“import org.apache.http.Header; 不可用
2016-08-10 14:46
447 查看
转载自:http://blog.csdn.net/jiangtianhao13269230/article/details/49447159
出处:http://www.zhihu.com/question/35597452/answer/63619567
Android studio中“import org.apache.http.Header;”没用?
ShinChven,使用:Xperia/Android/OSX/iOS/Ubuntu/Ce…
梁利晖、渡扬子 赞同
Android M 起默认移除了Apache HTTP:https://developer.android.com/intl/zh-cn/preview/behavior-changes.html
要使用的话,要这么干
1、在gradle-wrapper.properties中配置使用较新版本的gradle
distributionUrl=https://services.gradle.org/distributions/gradle-2.6-all.zip
2、在build.gradle中使用较新版本的gradle buildtools
buildscript {
repositories {
jcenter()
}
dependencies {
classpath ‘com.android.tools.build:gradle:1.3.0’
}
3、添加以下依赖,重新使用已经deprecated 的apache http 包:
android {
useLibrary ‘org.apache.http.legacy’
}
4、添加apache http component 的依赖,补全缺失的类,比如Header:
dependencies {
compile ‘org.apache.httpcomponents:httpcore:4.4.2’
}
我只使用了3、4条建议就可以了。
出处:http://www.zhihu.com/question/35597452/answer/63619567
Android studio中“import org.apache.http.Header;”没用?
ShinChven,使用:Xperia/Android/OSX/iOS/Ubuntu/Ce…
梁利晖、渡扬子 赞同
Android M 起默认移除了Apache HTTP:https://developer.android.com/intl/zh-cn/preview/behavior-changes.html
要使用的话,要这么干
1、在gradle-wrapper.properties中配置使用较新版本的gradle
distributionUrl=https://services.gradle.org/distributions/gradle-2.6-all.zip
2、在build.gradle中使用较新版本的gradle buildtools
buildscript {
repositories {
jcenter()
}
dependencies {
classpath ‘com.android.tools.build:gradle:1.3.0’
// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }
}
3、添加以下依赖,重新使用已经deprecated 的apache http 包:
android {
useLibrary ‘org.apache.http.legacy’
}
4、添加apache http component 的依赖,补全缺失的类,比如Header:
dependencies {
compile ‘org.apache.httpcomponents:httpcore:4.4.2’
}
我只使用了3、4条建议就可以了。
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories