android srudio使用HttpClient
2016-07-25 23:43
609 查看
最近学习Android网络编程,在AndroidStudio下无法使用HttpClient,在网上找到了答案在这里记下来;
//官方原文
Apache HTTP Client Removal
Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:
android {
useLibrary 'org.apache.http.legacy'
}
/*--------------------------------------------------------*/
原文地址:http://developer.android.com/intl/zh-cn/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/08/5b1b750fe0a5624085496da302bcaae2.png)
如图项目中有有两个build.gradle,其中一个没有Android{}的标记,App文件夹下面的那个才有;
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/08/d7b9f0a12758350fdf995576f31404a9.png)
添加完成,重新编译没有错误!
//官方原文
Apache HTTP Client Removal
Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:
android {
useLibrary 'org.apache.http.legacy'
}
/*--------------------------------------------------------*/
原文地址:http://developer.android.com/intl/zh-cn/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/08/5b1b750fe0a5624085496da302bcaae2.png)
如图项目中有有两个build.gradle,其中一个没有Android{}的标记,App文件夹下面的那个才有;
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/08/d7b9f0a12758350fdf995576f31404a9.png)
添加完成,重新编译没有错误!
相关文章推荐
- ubuntu14.04有线网配置(用于和嵌入式板子网络通讯)
- lamp+xcache完成指定服务
- 网络联机
- TCP和UDP都要限制
- 简单介绍各层作用
- 一些图论、网络流入门题总结、汇总
- LWIP网络接口管理
- nodejs--http
- APP开发实战120-APP网络流量优化
- Android 网络获取数据之XML解析
- TCP服务器
- 网络基础知识点总结1
- win 10 远程连接出现 "由于安全设置错误, 客户端无法连接到远程计算机. 确定你已登录到网络后.” 错误
- 手动编译安装httpd2.4.20 pcre-config错误解决
- 网络占卜大兴!能成下一个创业风口吗?
- 深度学习概述:从感知机到深度网络
- 网络编程之Socket ---TCP编程
- <JAVA学习笔记9>——网络之Socket的简单介绍
- muduo网络库学习笔记(0):面向对象编程风格和基于对象编程风格的比较
- 卷积神经网络问题总结