Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

Android SDK Manager 更新失敗:Failed to fetch URL 的解決方法

編輯:關於 Android 程式設計

使用 SDK Manager 更新時,常常會看到類似這樣的錯誤訊息:

Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list.xml, reason: Connection to https://dl-ssl.google.com refused

伴隨而來的還可能有以下幾種:

Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-6.xml, reason: Connection to https://dl-ssl.google.com refused

Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-1.xml, reason: Connection to https://dl-ssl.google.com refused

Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-1.xml, reason: hostname in certificate didn't match: <dl-ssl.google.com> != <www.google.com>

更新 ADT 時 also 會出現無法解析 https://dl-ssl.google.com/android/eclipse 的情況。

這些錯誤本質上都是同一件事:用戶端連不到 Google 的資源伺服器。

解決辦法:修改 hosts

最直接且更新速度最快的方式是改 hosts 檔。Windows 位於 C:\WINDOWS\system32\drivers\etc 目錄,Linux 則是 /etc/hosts。開啟後在檔案中補上以下幾行:

#Google 首頁
203.208.46.146 www.google.com

#方便開啟 Android 開發者官網
74.125.113.121 developer.android.com

#更新內容的來源
203.208.46.146 dl.google.com
203.208.46.146 dl-ssl.google.com

存檔後搭配 http 協定,就能正常更新。需要注意的是,這類 IP 對應關係會隨時間變動,若某天突然失效,找到一組可用的新 IP 替換即可。

改用 http 協定

開啟 SDK Manager.exe,切到 Tools 選單點 Android SDK Manager,把下方「Force https://... sources to be fetched using https://...」打勾。它的作用就是把受保護的 https 請求降級成一般 http,避開憑證hostname 不匹配的問題。

兩個步驟搭配使用效果最好:hosts 解決連線可達性,http 選項解決憑證驗證。以上就是 Android SDK Manager 更新失敗的處理方式。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved