Android studio中“import org.apache.http.xxx; 不可用
来源:互联网 发布:php 访问 编辑:程序博客网 时间:2024/04/28 07:22
前言
今天在使用旧项目已经封装好的java文件到AS的时候,文件里面的import org.apache.http.xxx几乎都是不可以通过的,百度了一下,原来是Android M启动了反荡妇机制,移除了Apache HTTP导致的,
解决办法
Android Studio2.0以上只需要进行3、4步即可
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'}
最后结果:
引用
[1] Android studio中“import org.apache.http.Header; 不可用 - jiangtianhao13269230的专栏 - 博客频道 - CSDN.NET
[2] Android M 起默认移除了Apache HTTP
0 0
- Android studio中“import org.apache.http.xxx; 不可用
- Android studio中“import org.apache.http.Header; 不可用
- Android studio中“import org.apache.http.Header; 不可用
- 解决Android Studio在使用android-async-http出现import org.apache.http.Header不可用
- Android studio中“import org.apache.http.Header;”没用?
- Android Studio 中org.apache.http.legacy解决办法
- android studio中报程序包org.apache.http不存在
- Android studio中“import org.apache.mina.core.session”报错
- org.apache.http.httpstatus 找不到,不可用的解决方法
- import org.apache.http.util.EncodingUtils找不到
- Android M 中org.apache.http添加
- Android Studio 中api>9 之后无法找到 org.apache.http 包的问题
- android studio 中 Error:(12, 23) 错误: 程序包org.apache.http不存在
- 11. 使用Android-async-http第三方库时import org.apache.http 导入无效
- Android Studio 编译不通过,报错“找不到org.apache.http。。。”
- Android Studio 编译不通过,报错“找不到org.apache.http。。。”
- Android Studio 中报错 程序包org.apache.http不存在 的解决方法
- Android Studio使用org.apache.http报错
- Java复习之IO打印流
- 转载了大神的一篇文章,关于表达式的二叉树遍历
- 1.2 单词翻转
- 64位 win7 安装pygame的问题(已解决)
- Windows环境下C源程序转换成可执行文件的过程
- Android studio中“import org.apache.http.xxx; 不可用
- JavaScript Namespace命名空间使用说明
- httpClient请求实例
- iframe中position:fixed失效
- SSH以及反向连接
- UVA, 465 Overflow
- Unity时间戳的使用教程
- git使用
- JavaScript数组函数unshift、shift、pop、push使用实例