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

reference to : http://blog.csdn.net/hbwindy/article/details/51326019

reference to : http://blog.csdn.net/yangqingqo/article/details/48214865

 

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

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

 那么只有再找办法,还真找到了:

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

do not need to copy sdk/platforms/android-23/optional/org.apache.http.legacy.jar into libs folder, system auto recoginise itself.

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

 proguard cofig :

 #不混淆org.apache.http.legacy.jar 
 -dontwarn android.net.compatibility.**
 -dontwarn android.net.http.**
 -dontwarn com.android.internal.http.multipart.**
 -dontwarn org.apache.commons.**
 -dontwarn org.apache.http.**
 -keep class android.net.compatibility.**{*;}
 -keep class android.net.http.**{*;}
 -keep class com.android.internal.http.multipart.**{*;}
 -keep class org.apache.commons.**{*;}
 -keep class org.apache.http.**{*;}

 

posted @ 2016-05-08 15:39  demoblog  阅读(3879)  评论(0编辑  收藏  举报