Android 6.0(API 23)中,Google已经移除了移除了Apache HttpClient相关的类、HttpResponse类。缺失jar包使用HttpResponse等会报错:

The type org.apache.http.HttpResponse cannot be resolved. It is indirectly referenced from required 

  1. //获取服务器Json数据
  2. HttpUtils httpUtils = new HttpUtils();
  3. //发送URL请求
  4. httpUtils.send(HttpMethod.GET,Myconstants.NEWCENTERURL,new RequestCallBack<String>() {
  5. @Override//访问数据成功
  6. public void onSuccess(ResponseInfo<String> responseInfo) {
  7. String jsonData =<u><span style="color:#ff0000;"> responseInfo</span></u>.result;
  8. System.out.println(jsonData);
  9. }
  10. @Override//访问数据失败
  11. public void onFailure(HttpException error, String msg) {
  12. System.out.println("网络请求数据失败"+error);
  13. }
  14. });
  1. //获取服务器Json数据
  2. HttpUtils httpUtils = new HttpUtils();
  3. //发送URL请求
  4. httpUtils.send(HttpMethod.GET,Myconstants.NEWCENTERURL,new RequestCallBack<String>() {
  5. @Override//访问数据成功
  6. public void onSuccess(ResponseInfo<String> responseInfo) {
  7. String jsonData =<u><span style="color:#ff0000;"> responseInfo</span></u>.result;
  8. System.out.println(jsonData);
  9. }
  10. @Override//访问数据失败
  11. public void onFailure(HttpException error, String msg) {
  12. System.out.println("网络请求数据失败"+error);
  13. }
  14. });

推荐使用HttpUrlConnection,如果要继续使用需要Apache  HttpClient,需要在eclipse下libs里添加org.apache.http.legacy.jar。添加方法如下:

1>、Eclipse中 在错误原因上点击ctrl+1,选择Configure build path,或者Project->Properties->Java Build Path->Libraries->Add Ecternal JARS->你的SDK目录的

\platforms\android-23\optional\org.apache.http.legacy.jar->ok

2>、android studio里在相应的module下的build.gradle中加入:

android {

useLibrary 'org.apache.http.legacy'

}


The type org.apache.http.HttpResponse cannot be resolved. It is indirectly referenced from required的更多相关文章

  1. 【ActiveMQ】管理界面查看消息详情,报错/WEB-INF/tags/form/forEachMapEntry.tag PWC6199: Generated servlet error: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

    ActiveMQ版本:5.12 JDK版本:1.8 ===================== 使用ActiveMQ过程中,在管理界面查看消息详情,发现报错: 查看日志信息,报错如下: 2017-11 ...

  2. The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from required .class files

    The type javax.servlet.http.HttpServletResponse cannot be resolved. It is indirectly referenced from ...

  3. Java微信开发_Exception_01_The type org.xmlpull.v1.XmlPullParser cannot be resolved. It is indirectly referenced from required .class files

    一.源码: package com.souvc.weixin.util; import java.io.InputStream; import java.io.Writer; import java. ...

  4. The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

    JDK版本的问题. 解决方法: 原来jdk1.8不向下兼容,用回1.6的就可以了. 下图有三个jdk,前两个自己装的,第三个MyEclipse自带的.

  5. The type javax.servlet.http.HttpServletRequest cannot be resolved. It is indirectly referenced from required .class files

    我的方法:是缺少servlet的引用库,解决如下 1.工程右键-properties->java build path 2.在java build path的libraries tab页中选择A ...

  6. The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced from required .class files

    使用spring框架提供的JDBC模板操作数据库时,提示错误 解决方案:导入事务管理jar包spring-tx-4.2.4.RELEASE.jar

  7. The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from required .class files

    我这个错误发生于导入项目的时候..我发现主要是jdk版本的问题.切换一下jdk.直接红叉消失就可以了.....jdk版本一致性还是很重要的

  8. The type javax.ws.rs.core.MediaType cannot be resolved. It is indirectly referenced from required .class files

    看到了http://stackoverflow.com/questions/5547162/eclipse-error-indirectly-referenced-from-required-clas ...

  9. The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.....

    遇到The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.....,查找的 ...

随机推荐

  1. Passward

    问题 A: Passward 时间限制: 1 Sec  内存限制: 512 MB 题目描述 你来到了一个庙前,庙牌上有一个仅包含小写字母的字符串 s. 传说打开庙门的密码是这个字符串的一个子串 t,并 ...

  2. ●BZOJ 2669 [cqoi2012]局部极小值

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2669 题解: 容斥,DP,DFS 先看看 dp 部分:首先呢,X的个数不会超过 8个.个数很 ...

  3. hihocoder1258(水)(2015ACM/ICPC北京站)

    题意: 给你B,C,S三种模式,当出现S时直接得分最多300(即perfect) 当是B,C时后面会跟一个数字,当后面的数字是从1开始的连续时,直接得分最多300(即perfect) 问给你一系列,最 ...

  4. hdu 5573Binary Tree

    Binary Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tota ...

  5. Linux LCD 显示图片【转】

    转自:https://blog.csdn.net/niepangu/article/details/50528190 BMP和JPEG图形显示程序1)  在LCD上显示BMP或JPEG图片的主流程图首 ...

  6. python3 条件判断,循环,三元表达式

    一. 条件判断 条件判断的关键字if elif else,具体规则如下: if condition_1: statement_block_1 elif condition_2: statement_b ...

  7. Git常用命令及常见问题解决

    $ mkdir xxx       ----创建xxx目录 $ cd learngit     ----切到xxx目录下 $ pwd               ----查看当前文件所在目录 $ gi ...

  8. 试说明采用双缓冲技术如何进行I/O操作

    输入设备先将第一个缓冲区装满数据,在输入设备向第二个缓冲区装数据时,处理机就可以从第一个缓冲区取出数据进行处理:当一个缓冲区的数据处理完毕,若第二个缓冲区已经装满,则处理机又可以从第二个缓冲区取出数据 ...

  9. Android自定义模糊匹配搜索控件(二)

    在项目中遇到一个需要通过某个字的值筛选匹配带出其他信息的需求,在这里将实现思路整理出来. 源码地址:https://github.com/whieenz/SearchSelect 先看效果图 上图中的 ...

  10. AspNetCoreApi 跨域处理

    AspNetCoreApi 跨域处理 如果咱们有处理过MV5 跨域问题这个问题也不大. (1)为什么会出现跨域问题:  浏览器安全限制了前端脚本跨站点的访问资源,所以在调用WebApi 接口时不能成功 ...