[原創]在使用SDK 23(6.0)版本后org.apache.http相關的類找不到的解決辦法


參考:
 
 
1. 在Android模塊里面添加
android {
    useLibrary 'org.apache.http.legacy'
}
 
這個對我不起作用,依然提示 不識別 org.apache.http.legacy
 
 
更新:發現在 SDK/platforms/android-23/optional 下面其實是有org.apache.http.legacy這個文件的。在這個目錄下新建 optional.json, 內容如下:
==========
[ { "name": "org.apache.http.legacy", "jar": "org.apache.http.legacy.jar", "manifest": false } ]
===========
然后這個方法生效。(誰動了我的optional.json ?!)
 
2. 在Dependency中添加:
dependencies {
    compile 'org.apache.httpcomponents:httpcore:4.4.2'
}
 
這個親測有效!! ^_^
 
3. 在Dependency中添加:
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
 
沒有測試,估計有效。看別人的回復:
 

You can simply add this to Gradle dependencies:

compile "org.apache.httpcomponents:httpcore:4.3.2"
========================
This helps. But still not enough if you want to use other classes like HttpGet. For that I used compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.cli‌​ent:4.1.2' – AlexAndro Oct 5 '15 at 9:10
 
在Dependency中添加以后, Gradle會自動從server下載所需要的依賴。好神奇。。。似乎是下載到了SDK的目錄?


免責聲明!

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



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