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. [UVa 1326]Jurassic Remains

    题解 在一个字符串中,每个字符出现的次数本身是无关紧要的,重要的只是这些次数的奇偶性,因此想到用一个二进制的位表示一个字母($1$表示出现奇数次,$0$表示出现偶数次).比如样例的$6$个数,写成二进 ...

  2. [SCOI 2016]背单词

    Description Lweb 面对如山的英语单词,陷入了深深的沉思,“我怎么样才能快点学完,然后去玩三国杀呢?”.这时候睿智 的凤老师从远处飘来,他送给了 Lweb 一本计划册和一大缸泡椒,他的计 ...

  3. [JLOI2015]管道连接

    题目描述 小铭铭最近进入了某情报部门,该部门正在被如何建立安全的通道连接困扰.该部门有 n 个情报站,用 1 到 n 的整数编号.给出 m 对情报站 ui;vi 和费用 wi,表示情报站 ui 和 v ...

  4. hdu 5052 树链剖分

    Yaoge’s maximum profit Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/ ...

  5. *hdu 5536(字典树的运用)

    Input The first line of input contains an integer T indicating the total number of test cases. The f ...

  6. 将 Hexo 个人博客同时部署到 GitHub 和 Coding 上

    一.将个人博客托管到 GitHub 上 关于如何快速搭建自己的个人博客,如何完善自己的个人博客,什么是 GitHub ,如何将自己的博客代码托管到 GitHub 上面等等问题,我之前写过三篇文章已经做 ...

  7. mysql 拼接

    SELECT  RTRIM(CONCAT(belong_master_ip ,'(',host_name,')')) AS cloudIP  FROM `cloud_master_cfg`

  8. React Suite v3.0 正式版发布

    React Suite v3.0 正式版发布 相信很多人会好奇,React Suite 是什么? React Suite 是 HYPERS 前端团队和 UX 团队开源的一套基于 React 的 UI ...

  9. jdk1.7和jdk1.8区别

    转自:http://www.2cto.com/kf/201307/225968.html 本文是我学习了解了jdk7和jdk8的一些新特性的一些资料,有兴趣的大家可以浏览下下面的内容. 官方文档:ht ...

  10. JS运行机制之 Event Loop 的思考

    先举个栗子,如下: for (var i = 0; i < 5; i++) { setTimeout(function() { console.log('i: ',i); //一秒之后输出几乎没 ...