gpt4 book ai didi

android - Gradle 同步成功后无法在 Android Studio 中使用 HttpPost

转载 作者:行者123 更新时间:2023-11-29 14:46:15 25 4
gpt4 key购买 nike

我正在尝试像过去在 Android 中那样使用 HttpPost。我意识到它已从最近的 Android 版本中删除。按照类似 StackOverflow 问题的解决方案,我将其添加到我的 Gradle 依赖项中:

compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'

在提示没有错误的 Gradle 同步之后,我仍然无法导入 HttpPost 程序。事实上,org.apache.http.client.methods 包根本没有解析。

我还尝试了 Apache HttpClient 网站的建议,即在我的 Gradle 依赖项中使用它:

compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'

再一次,同步正常,这次包被解析,但 HttpPost 程序没有解析。

enter image description here

如有任何建议,我将不胜感激。

最佳答案

只需在 android 插件内的 build.gradle 中添加这一行:

useLibrary 'org.apache.http.legacy'

关于android - Gradle 同步成功后无法在 Android Studio 中使用 HttpPost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36780499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com