【发布时间】:2018-03-06 13:34:23
【问题描述】:
我正在尝试使用httpclient-4.5.5 编写HttpPost 请求。
我在httpPost.setConfig(requestConfig); 行中收到error
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(mEntityBuilder.build());
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(timeout)
.setConnectTimeout(timeout).setSocketTimeout(timeout)
.build();
httpPost.setConfig(requestConfig);
HttpResponse response = httpClient.execute(httpPost);
错误是 - Error:(97, 21) error: cannot find symbol method setConfig(RequestConfig)
我查看了 HttpPost 类,它扩展了 HttpEntityEnclosureRequestBase,后者又扩展了具有公共方法 setConfig 的 HttpRequestBase。
请帮帮我。
【问题讨论】:
-
我在 app gradle 文件中添加了 android {useLibrary 'org.apache.http.legacy'} 行。我已将 httpclient-4.5.5 jar 模块添加到我的 android 项目中。
标签: android apache httpclient apache-httpclient-4.x