Android API 23中废弃了HttpClient的解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hbwindy/article/details/51326019

今天在写网络连接的时候发现 API 23 中居然找不到 HttpClient,官方文档似乎是这样说的。

This interface was deprecated in API level 22.
Please use openConnection() instead. Please visit this webpage for further details.

要我用 openConnection() 代替,然而并不会用,以后再研究吧。
那么只有再找办法,还真找到了:

To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

android {

        useLibrary 'org.apache.http.legacy'
}

问题解决了。

猜你喜欢

转载自blog.csdn.net/hbwindy/article/details/51326019