java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE

Android发出HTTP请求时出现了这个错误:

java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE

这是由于使用了CloseableHttpClient造成的,把

CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse httpResponse = httpclient.execute(httpRequest);

替换成

HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResponse = httpclient.execute(httpRequest);

即可。

CloseableHttpClient在Windows下可以使用,在Android下使用就会出错,原因不明。

 

posted @ 2016-12-13 16:50  MSTK  阅读(2541)  评论(0编辑  收藏  举报