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下使用就会出错,原因不明。

04-13 18:09