您的位置:首页 > 理论基础 > 计算机网络

Android studio中“import org.apache.http.Header; 不可用

2015-10-27 13:36 465 查看
出处: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'
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: