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错误.....,查找的 ...
随机推荐
- permu(变态考试题)
题目描述 给定一个严格递增的序列T,求有多少个T的排列S满足:∑min(T[i],S[i])=k 输入输出格式 输入格式: 第一行两个数n,k 第二行n个数,表示T 输出格式: 一个正整数表示答案,答 ...
- 【BZOJ1026】【SCOI2009】windy数
Description windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道,在A和B之间,包括A和B,总共有多少个windy数? In ...
- hdu 5119(2014北京)
题意: 随机选择一个数,如果后面有比他小的就进行交换,直到没有为止(算一轮).求多少轮后为递增序列 思路: 倒着找,如果有比经过的最小数大的,ans+1 #include <iostream&g ...
- UVA 1481 Genome Evolution
Xi, a developmental biologist is working on developmental distances of chromosomes. A chromosome, in ...
- [bzoj4922]Karp-de-Chant Number
来自FallDream的博客,未经允许,请勿转载,谢谢. 卡常数被称为计算机算法竞赛之中最神奇的一类数字,主要特点集中于令人捉摸不透,有时候会让水平很高的选手迷之超时. 普遍认为卡常数是埃及人Qa'a ...
- Notepad++连接Centos
Notepad++设置 插件 -- > plugin Manager --> show plugin manager --> NppFtp 安装重启notepad++ 插件 --& ...
- 假定某系统提供硬件的访管指令(例如形式:“svc n”),为了实现系统调用,系统设计者应做哪些工作?用户又如如何请求操作系统服务?
工作: 1. 编写并调试好能实现各种功能的例行子程序. 2. 编写并调试好访管中断处理程序. 3. 构造例行子程序入口地址表. 在用户程序中,需要请求操作系统服务的地方安排一条系统调用.这样,当 ...
- Mianbot:基于向量匹配的情境式聊天机器人
Mianbot是采用样板与检索式模型搭建的聊天机器人,目前有两种产生回覆的方式,专案仍在开发中:) 其一(左图)是以词向量进行短语分类,针对分类的目标模组实现特征抽取与记忆回覆功能,以进行多轮对话,匹 ...
- .eslintrc 文件
安装 建议采用全局安装方式 npm install -g eslint 初始化 如果你的项目还没有配置文件(.eslintrc)的话,可以通过指定–init参数来生成一个新的配置文件: `eslint ...
- Mac上安装brew 包管理工具
Mac 上的包管理工具对于开发者来说是一件非常方便的工具,能够有效的对包进行管理. 所以这篇博客就来简单的讲一下brew 的安装和一些基础命令. brew 全称叫做Homebrew . 1. 首先来说 ...