1. 程式人生 > >Android 6.0中"Unable to find optional library: org.apache.http.legacy"錯誤解決

Android 6.0中"Unable to find optional library: org.apache.http.legacy"錯誤解決

Android 6.0版本已經已經基本將Apahce Http Client 移除出SDK,會報出以下錯誤:

" Unable to find optional library: org.apache.http.legacy"

 那麼問題來了,如果我在以前的專案中使用了Apache HttpClient相關類,怎麼辦呢?

請看官網給出的解決

Apache HTTP Client Removal

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  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'}
也就是在build.gradle中加入上面的配置就行了。

解決辦法:

     1、看看目錄D:\Android\sdk\platforms\android-23\optional 下有沒有org.apache.http.legacy.jar 和 optional.json

     2、如果沒有optional.json,則自己新建一個這樣的檔案,然後加入如下內容:

  1. [  
  2.   {  
  3.     "name": "org.apache.http.legacy",  
  4.     "jar": "org.apache.http.legacy.jar",  
  5.     "manifest": false  
  6.   }  
  7. ]  

相關推薦

Android 6.0"Unable to find optional library: org.apache.http.legacy"錯誤解決

Android 6.0版本已經已經基本將Apahce Http Client 移除出SDK,會報出以下錯誤: " Unable to find optional library: org.apache.http.legacy"  那麼問題來了,如果我在以前的專案中使用

Android 專案報錯 Error:Unable to find optional library: org.apache.http.legacy

Eclipse 專案移植到AndroidStduio 後 執行報錯Error:Unable to find optional library: org.apache.http.legacy Android 6.0版本已經已經基本將Apahce Http Client 移

Android stuido 錯誤:Error:Unable to find optional library: org.apache.http.legacy

今天在匯入新專案的時候出現了一個從來都沒有見過的錯誤,讓我鬱悶了很久,在網上也找了很多一樣錯誤解決方法,但是最終也是沒有解決,不能說網上的解決方法是錯誤,只能說網上的解決辦法是最基礎的,有時候不能夠解決問題,錯誤的截圖如下: 網上的解決辦法是: 1.   API23

android studio碰到無法找到org.apache.http.legacy解決辦法

寫程式碼時遇到如下問題通常是因為使用了sdk23的最新版的原因 解決辦法如下: 開啟sdk的目錄,找到如下路徑 \sdk\platforms\android-23\optional 在該路徑中新增缺少的jar包:org.apache.http.legacy.jar ps:該

Spark 2.0 DataFrame map操作Unable to find encoder for type stored in a Dataset.問題的分析與解決

隨著新版本的spark已經逐漸穩定,最近擬將原有框架升級到spark 2.0。還是比較興奮的,特別是SQL的速度真的快了許多。。 然而,在其中一個操作時卻卡住了。主要是dataframe.map操作,這個之前在spark 1.X是可以執行的,然而在spark 2.0上卻無

Android 6.0 新的新技術

七、低功耗藍芽掃描優化   優化了低功耗藍芽掃描優化的掃描。現在低功耗藍芽的應用越來越多,很多 APP 都需要掃描裝置,掃描裝置是一個非常重的操作,希望這次改動,能夠帶來一些改善。   八、支援主題化的 ColorStateLists   使用

Android 6.0SELinux的TE簡介

在開發中,偶爾會碰到一些TE字尾的檔案的修改和檢視。google借鑑了SELinux安全機制,在Android內包含了該機制,而TE是SELinux中描述程式訪問資源的語言。本文的目的是讓大家在Android開發中,碰到相關問題時能夠看懂相關的TE檔案。在下面的內容中將描述SEL

Android 6.0art虛擬機器編譯dex時已完全放棄使用LLVM

記得在Android 4.4釋出的時候,Google正式引入了稱做ART(Android Run Time)的虛擬機器,用來取代傳統的Dalvik虛擬機器。 ART虛擬機器最大的特點就是,將程式碼優化的過程從Davlik的JIT(Just In Time)模式轉換成了AOT

匯入android工程出現:unable to get system library for the project

匯入android工程的時候出現了 :  unable to get system library for the project 解決問題的方法是開啟工程中的project.properties檔案,把版本號改成本機版本   比如: target=a

Android studio出現Error:Unable to tunnel through proxy. Proxy returns "HTTP/1.1 400 Bad Reques的解決辦法

最近更新了一下Android Studio,在匯入新專案之後出現Error:Unable to tunnel through proxy. Proxy returns “HTTP/1.1 400 Bad Request”的錯誤,如下圖所示: 經過檢查後發現這裡是丟失了android studio的gradl

android studio提示Error:Unable to tunnel through proxy. Proxy returns "HTTP/1.1 400 Bad Reques

解決方法:1.studio裡面->setting->Build,Execution,Deployment裡面的Gradle->配置此專案的gradle檔案路徑為studio應用所使用的版本路徑(如果還報錯,檢視gradle版本是否與studio版本一致)

android 訪問localhost:8080 報錯org.apache.http.conn.HttpHostConnectException

報這個錯 一上來肯定想不明白以前作任何網路開發 先訪問本地服務localhost:8080作測試很正常。也沒出過什麼問題但是今天作android開發,先在本機8080埠上搭建一個服務,然後從模擬器上訪問該服務時報出了org.apache.http.conn.HttpHost

spring boot項目升級到2.0.1,提示java.lang.ClassNotFoundException: org.apache.log4j.Logger錯誤

ava lan 簡單 src AS dex ack pen pid 首先肯定是版本出現了一點兼容問題 所以我就進入項目,查看依賴樹,cd到項目目錄下,mvn dependency:tree 我看到我的項目原先是1.5.9和現在2.0.1的區別在於org.slf4j的依賴不全

Android Studio解決org.apache.http.legacy找不到的問題

SDK升級到6.0後,不再支援 Apache HTTP client,會報出了這個錯誤,想要解決這個錯誤,根據百度的方法,在工程build.gradle下新增以下程式碼: android { useLibrary 'org.apache.htt

關於maven的 Failed to execute goal org.apache.maven.plugins錯誤解決方案

一般eclipse 4之後的版本都會有maven外掛這時我們就不用再下載Maven外掛了,但當執行maven的Pom.xml檔案時會出現下列錯誤: [INFO] Scanning for projects... [INFO]                        

can't find referenced class okhttp3.internal.http.HttpEngine錯誤解決

工程build apk時報錯 Error:11:23:00.724 [ERROR] [system.err] Warning: okhttp3.logging.HttpLoggingInterce

Android學習筆記》Android Studio匯入org.apache.http.legacy.jar教程/匯入API教程

【更新時間】 2017/4/5 【序】 因為在學習一個demo要用到http請求,但是出現了org.apache.http.Header這個類找不到的情況,原因是在API 23中,不提供org.apache.http.*(只保留幾個類),今天的教程就是

Android CTS測試./cts-tradefed出現Unable to find aapt in path 解決方案

cts測試,本來測試得好好的,關閉終端後重新開啟,再次開啟,執行./cts-tradefed命令出錯,顯示Unable to find aapt in path  解決方案: 1.安裝aapt 輸入sudo apt-get install aapt 安裝成功後重新輸入

64位win7使用vs2013為python3.4安裝pycrypto-2.6.1外掛報Unable to find vcvarsall.bat異常解決方案

問題描述: 64位win7中使用vs2013為python3.4.2安裝pycrypto-2.6.1外掛報Unable to find vcvarsall.bat。 問題分析: 1、原始碼分析,查詢python原始碼distribut模組中出現Unable to find

Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.6.RELEASE:repackage failed: Unable to find main class

spl final package exce main project clas ini exit 異常 [INFO] --- spring-boot-maven-plugin:1.5.6.RELEASE:repackage (default) @ spring-boot