[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.**{*;}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM