作者:tomphilip_399_140 | 来源:互联网 | 2023-05-18 03:45
今天打开以前的项目突然发现ApacheHttpClient相关类不能使用了。官方文档给出的解释是:Android6.0releaseremovessupportfortheApac
今天打开以前的项目突然发现 Apache HttpClient 相关类不能使用了。
官方文档给出的解释是:
Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API
level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through
transparent compression and response caching, and minimizes power consumption. 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 '
}
简单说,就是在 Android Studio 项目的 build.gradle 中添加
android {
useLibrary 'org.apache.http.legacy'
}
配置信息即可,不过还是推荐使用 HttpURLConnection 相关类。