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

 

相关文章:

  • 2022-12-23
  • 2022-03-01
  • 2022-12-23
  • 2021-07-20
  • 2021-06-13
  • 2021-12-22
  • 2022-12-23
猜你喜欢
  • 2022-01-23
  • 2021-09-20
  • 2021-08-02
  • 2022-01-17
  • 2021-11-29
  • 2022-12-23
相关资源
相似解决方案