The type org.apache.http.HttpResponse cannot be resolved. It is indirectly referenced from required
在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
- //获取服务器Json数据
- HttpUtils httpUtils = new HttpUtils();
- //发送URL请求
- httpUtils.send(HttpMethod.GET,Myconstants.NEWCENTERURL,new RequestCallBack<String>() {
- @Override//访问数据成功
- public void onSuccess(ResponseInfo<String> responseInfo) {
- String jsonData =<u><span style="color:#ff0000;"> responseInfo</span></u>.result;
- System.out.println(jsonData);
- }
- @Override//访问数据失败
- public void onFailure(HttpException error, String msg) {
- System.out.println("网络请求数据失败"+error);
- }
- });
- //获取服务器Json数据
- HttpUtils httpUtils = new HttpUtils();
- //发送URL请求
- httpUtils.send(HttpMethod.GET,Myconstants.NEWCENTERURL,new RequestCallBack<String>() {
- @Override//访问数据成功
- public void onSuccess(ResponseInfo<String> responseInfo) {
- String jsonData =<u><span style="color:#ff0000;"> responseInfo</span></u>.result;
- System.out.println(jsonData);
- }
- @Override//访问数据失败
- public void onFailure(HttpException error, String msg) {
- System.out.println("网络请求数据失败"+error);
- }
- });
推荐使用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的更多相关文章
- 【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 ...
- 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 ...
- 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. ...
- The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
JDK版本的问题. 解决方法: 原来jdk1.8不向下兼容,用回1.6的就可以了. 下图有三个jdk,前两个自己装的,第三个MyEclipse自带的.
- 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 ...
- 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
- The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from required .class files
我这个错误发生于导入项目的时候..我发现主要是jdk版本的问题.切换一下jdk.直接红叉消失就可以了.....jdk版本一致性还是很重要的
- 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 ...
- 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错误.....,查找的 ...
随机推荐
- ●洛谷P3242 [HNOI2015]接水果
题链: https://www.luogu.org/problemnew/show/P3242 题解: 整体二分,扫描线+树状数组. 详细的题解:http://blog.csdn.net/thy_as ...
- ●BZOJ 3561 DZY Loves Math VI
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=3561 题解: 莫比乌斯反演 $$\begin{aligned}ANS&=\sum_{ ...
- ●BZOJ 1853 [Scoi2010]幸运数字
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1853 题解: 容斥原理,暴力搜索,剪枝(这剪枝剪得真玄学) 首先容易发现,幸运号码不超过 2 ...
- hdu4605 树状数组+离散化+dfs
Magic Ball Game Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- [BZOJ]1059 矩阵游戏(ZJOI2007)
虽然说是一道水题,但小C觉得还是挺有意思的,所以在这里mark一下. Description 小Q是一个非常聪明的孩子,除了国际象棋,他还很喜欢玩一个电脑益智游戏——矩阵游戏.矩阵游戏在一个N*N黑白 ...
- 【集训第三天·疯狂训练】哦,顺带学习了manacher
虽然说是疯狂训练吧,但是也没写多少题,就把伸展树的操作熟悉了一下,ac了5个题目. 一整天没啥可吐槽的,除了昨天在机房打游戏的某位朋友翻车后和教练谈了谈心2333 说题吧.. 1.BZOJ1208 H ...
- bzoj3294[Cqoi2011]放棋子 dp+组合+容斥
3294: [Cqoi2011]放棋子 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 755 Solved: 294[Submit][Status] ...
- C语言成语设计第一次作业
一 1.求圆面积和周长 输入圆的半径,计算圆的周长和面积. 2.流程图 3.测试数据及运行结果 测试数据:r=7 运行结果 4.实验分析 问题:第一次输入提示时未加双引号 解决办法:发现问题后加了双引 ...
- dva-quickstart 与 create-react-app 比较(一)
最近在学习 React , 现对 dva-quickstart 与 create-react-app 比较 1. 安装, 两个都需要安装工具包:npm install -g create-re ...
- left join 连表时,on后多条件无效问题
http://www.cnblogs.com/guixiaoming/p/6516261.html left join 连表时,on后多条件无效问题 最近开发素材库项目,各种关系复杂的表,一度6张表的 ...