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错误.....,查找的 ...
随机推荐
- js eval函数写一个简单的计算器
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- [JSOI 2008]星球大战starwar
Description 题库链接 给你一张 \(n\) 点, \(m\) 条边的无向图,每次摧毁一个点,问你剩下几个联通块. \(1\leq n\leq 2m,1\leq m\leq 200000\) ...
- [HNOI 2015]亚瑟王
Description 小 K 不慎被 LL 邪教洗脑了,洗脑程度深到他甚至想要从亚瑟王邪教中脱坑. 他决定,在脱坑之前,最后再来打一盘亚瑟王.既然是最后一战,就一定要打得漂 亮.众所周知,亚瑟王是一 ...
- 计蒜客模拟赛5 D2T2 蚂蚁搬家
很久很久以前,有很多蚂蚁部落共同生活在一片祥和的村庄里.但在某一天,村庄里突然出现了一只食蚁兽,蚂蚁们为了保全性命而决定搬家. 然而这个村庄四面环山,想要离开这个村庄必须要从地洞里离开,村子里一共有 ...
- hdu 5491(位运算)
题意:给你n,a,b. 希望得到比n大,二进制1的个数在 a ,b之间的最小的数 思路:①满足条件,输出 ②num < a 从右找到是0的最小位,变成1 ③num > b从右到左找是1的最 ...
- [USACO08JAN]跑步Running
题目描述 The cows are trying to become better athletes, so Bessie is running on a track for exactly N (1 ...
- bzoj2434阿狸的自动机
转载自 http://www.cnblogs.com/zj75211/p/6934976.html ●BZOJ 2434: [Noi2011]阿狸的打字机 ●赘述题目 (题意就不赘述了) ●解法: ...
- C++函数式编程实现牛顿法
In numerical analysis, Newton's method (also known as the Newton–Raphson method), named after Isaac ...
- Java Servlet 笔记2
1. Servlet的生命周期 Servlet 通过调用 init () 方法进行初始化. Servlet 调用 service() 方法来处理客户端的请求. Servlet 通过调用 destroy ...
- c语言3种链接属性: 外部(external), 内部(internal),无设置(none)
c语言中,多个文件组合的时候,有可能标示名相同,那么这个时候编译器如何判别的呢? c语言中有3种链接属性: 外部(external), 内部(internal),无设置(none) 外部( ...