The type org.apache.http.HttpResponse cannot be resolved. It is indirectly referenced from required

翻译 2016年08月31日 08:49:47

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.   
  4. //发送URL请求  
  5. httpUtils.send(HttpMethod.GET,Myconstants.NEWCENTERURL,new RequestCallBack<String>() {  
  6.       
  7.     @Override//访问数据成功  
  8.     public void onSuccess(ResponseInfo<String> responseInfo) {  
  9.         String jsonData =<u><span style="color:#ff0000;"> responseInfo</span></u>.result;  
  10.         System.out.println(jsonData);  
  11.     }  
  12.   
  13.     @Override//访问数据失败  
  14.     public void onFailure(HttpException error, String msg) {  
  15.         System.out.println("网络请求数据失败"+error);  
  16.     }  
  17. });  
  1. //获取服务器Json数据  
  2. HttpUtils httpUtils = new HttpUtils();  
  3.   
  4. //发送URL请求  
  5. httpUtils.send(HttpMethod.GET,Myconstants.NEWCENTERURL,new RequestCallBack<String>() {  
  6.       
  7.     @Override//访问数据成功  
  8.     public void onSuccess(ResponseInfo<String> responseInfo) {  
  9.         String jsonData =<u><span style="color:#ff0000;"> responseInfo</span></u>.result;  
  10.         System.out.println(jsonData);  
  11.     }  
  12.   
  13.     @Override//访问数据失败  
  14.     public void onFailure(HttpException error, String msg) {  
  15.         System.out.println("网络请求数据失败"+error);  
  16.     }  
  17. });  

推荐使用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

在Android 6.0(API 23)中,Google已经移除了移除了Apache HttpClient相关的类、HttpResponse类。缺失jar包使用HttpResponse等会报错: T...

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包会报错:The typ...

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

新建包和类后报错:The type java.lang.Object cannot be resolved. It is indirectly referenced from required .c...

The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced

springMVC /jdbcTemplate

The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from req

JDK从1.7变成1.8,Myeclipse10.0导入之前的工程提示如下错误:Description Resource Path Location Type The project...

Eclipse的java代码出错:The import org.apache cannot be resolved

Eclipse中,折腾java代码。 把之前在android中的代码拿过来使用。 结果出现The import org.apache cannot be resolved的错误:   【解决过...
  • wdk1011
  • wdk1011
  • 2017年07月23日 15:51
  • 164

Eclipse的java代码出错:import org.apache cannot be resolved

【问题】 Eclipse中,折腾java代码。 把之前在android中的代码拿过来使用。 结果出现Theimport org.apache cannot be resolved的错误: ...

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be res

1、错误描述严重: Servlet.service() for servlet [jsp] in context with path [/cmp] threw exception [The absol...

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolve

错误是因为引入jsp中而你却没有引入相关jar包: com.springsource.javax.servlet.jsp.jstl-1.1.2.jar com.springsource.org.a...

解决:The import org.springframework.test.context.junit4.SpringJUnit4ClassRunner cannot be resolved

近期自己在自家新电脑上搭建了Eclipse + Maven环境,然后在做单元测试的时候,创建Spring测试类,在为测试类添加@RunWith(SpringJUnit4ClassRunner.clas...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:The type org.apache.http.HttpResponse cannot be resolved. It is indirectly referenced from required
举报原因:
原因补充:

(最多只允许输入30个字)