美文网首页
Android 6.0 SDK无法使用HttpClient的解决

Android 6.0 SDK无法使用HttpClient的解决

作者: 王晨彦 | 来源:发表于2016-01-25 15:32 被阅读1957次

前言

转自Google官博
*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. *

Google为了强推HttpURLConnection,直接在Android 6.0 SDK中移除了Apache HttpClient库支持,不过并没有把这条路堵死,并给出了解决办法,看来Google也不敢乱来啊_

解决办法

eclipse ADT

libs中加入.\sdk\platforms\android-23\optional\org.apache.http.legacy.jar

Android Studio

在对应的Module下的build.gradle中加入:

android {
    useLibrary 'org.apache.http.legacy'
}

虽然Google给出了解决办法,但还是推荐大家使用轻量级的HttpURLConnection,毕竟官方支持。

相关文章

网友评论

      本文标题:Android 6.0 SDK无法使用HttpClient的解决

      本文链接:https://www.haomeiwen.com/subject/sgxdkttx.html