Android 6.0版本已经已经基本将Apahce Http Client移除出SDK,会报出以下错误:

" Unable to find optional library: org.apache.http.legacy"

那么问题来了,如果我在以前的项目中使用了Apache 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 theHttpURLConnectionclass 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 yourbuild.gradlefile:

android {  useLibrary 'org.apache.http.legacy'}
也就是在build.gradle中加入上面的配置就行了。


解决办法:

1、看看目录D:\Android\sdk\platforms\android-23\optional 下有没有org.apache.http.legacy.jar 和optional.json

2、如果没有optional.json,则自己新建一个这样的文件,然后加入如下内容:


[html] view plain
  1. [
  2. {
  3. "name":"org.apache.http.legacy",
  4. "jar":"org.apache.http.legacy.jar",
  5. "manifest":false
  6. }
  7. ]

更多相关文章

  1. android 获取唯一标识
  2. Android获取设备唯一标识完美解决方案
  3. android 设置linelayout让按钮自动适应屏大小
  4. Android(安卓)Activity全屏显示
  5. 关于ANDROID NATIVE 的No implementation found for native问题
  6. 为Android加入busybox工具
  7. 在Android中加入GOOGLE统计系统
  8. 在Android中加入GOOGLE统计系统
  9. 在Android中加入GOOGLE统计系统

随机推荐

  1. android命令备忘
  2. android studio 编译问题,依赖找不到
  3. 100+Android 开源项目分类汇总一(精品 )
  4. android逆向神器之firda
  5. Android------底部导航栏BottomNavigatio
  6. Android发光特效焦点框-遥控器版本
  7. Android O 上设置中battery saver 模块讲
  8. Android学习心得(14) --- Android代码混淆(2)
  9. Android中BaseAdapter用法示例
  10. Android系统添加全局快捷键的方法