Android 9.0/P 開發問題及解決方案彙總

1、使用 org.apache.http.legacy 庫在Android 9.0上運行出現崩潰

日誌內容:

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/message/BasicNameValuePair

或者html

java.lang.RuntimeException: Stub!
  at org.apache.http.message.BasicNameValuePair.<init>(BasicNameValuePair.java:6)

問題分析:

出現此問題主要是 apache 的 http 庫在android 9.0刪除致使的,出現此問題應該是使用了 apache 的http庫。java

修改建議:

儘可能不要再使用httpClient來訪問網絡,替換成HttpURLConnection或者OKHttp。最後再說明一下:儘可能不要使用過期的庫進行開發
android

參考連接:Android 9.0/P 版本推薦使用 HttpURLConnection,棄用 Apache HTTPClientapache

相關文章
相關標籤/搜索