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. bzoj1272 Gate Of Babylon

    [问题描述] [输入格式] [输出格式] [样例输入] 2 1 10 13 3 [样例输出] 12 [样例说明] [数据范围] 先容斥,考虑枚举哪些条件强制不满足,即直接选出b[i]+1件宝具 假设强 ...

  2. ●BZOJ 3998 [TJOI2015]弦论

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=3998题解: 后缀自动机. 当T=0时, 由于在后缀自动机上沿着trans转移,每个串都是互不 ...

  3. bzoj 1974: [Sdoi2010]代码拍卖会

    Description 随着iPig在P++语言上的造诣日益提升,他形成了自己一套完整的代 码库.猪王国想参加POI的童鞋们都争先恐后问iPig索要代码库.iPi g不想把代码库给所有想要的小猪,只想 ...

  4. Java Servlet 笔记1

    1. 什么是Servlet. Java Servlet 是运行在 Web 服务器或应用服务器上的程序,它是作为来自 Web 浏览器或其他 HTTP 客户端的请求和 HTTP 服务器上的数据库或应用程序 ...

  5. jvm 指令集代码

    指令码 助记符 说明 0x00 nop 什么都不做 0x01 aconst_null 将null推送至栈顶 0x02 iconst_m1 将int型-1推送至栈顶 0x03 iconst_0 将int ...

  6. CSS之绝对定位

    w3school定义: 绝对定位的元素的位置相对于最近的已定位祖先元素(这里的已定位指的是绝对定位或者相对定位),如果元素没有已定位的祖先元素,那么它的位置相对于最初的包含块. 对于定位的主要问题是要 ...

  7. 我的博客地址和github地址

    博客地址 http://www.cnblogs.com/sjzsjzsjz/ github地址  https://github.com/sjzsjzsjz

  8. JAVA (集合和数据结构)

    Collection和Collections的区别: 1.java.util.Collection 是一个集合接口.它提供了对集合对象进行基本操作的通用接口方法.Collection接口在Java 类 ...

  9. Axios 使用文档

    Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中. 使用实例:http://www.cnblogs.com/coolslider/p/7838309.ht ...

  10. 【python进阶】Garbage collection垃圾回收1

    前言 GC垃圾回收在python中是很重要的一部分,同样我将分两次去讲解Garbage collection垃圾回收,此篇为Garbage collection垃圾回收第一篇,下面开始今天的说明~~~ ...