更新时间:2021-10-24 05:50:05
如果您将 compileSdkVersion
更改为 21,您的应用程序将干净利落地编译.话虽如此,Google 退出内置 HttpClient 实现是有原因的,因此您可能应该寻求其他一些库.那其他图书馆"可能是:
If you change your compileSdkVersion
to 21, your app will compile cleanly. That being said, there are reasons why Google is backing away from the built-in HttpClient implementation, so you probably should pursue some other library. That
"some other library" could be:
HttpUrlConnection
,尽管如您所见,它的 API 仍有不足之处HttpUrlConnection
, though as you have found, its API leaves something to be desired特别是 OkHttp 似乎有一个非常好的 API 用于发布文件和 发布多部分表单,这应该类似于您的 HttpClient 代码
In particular, OkHttp seems to have a pretty good API for posting a file and posting a multipart form, which should be similar to what your HttpClient code is doing.