Android SDK 更新失败解决 Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-6.xml

本文针对SDKManager更新失败的问题提供了解决方案,包括配置http协议、修改hosts文件等方法,并详细介绍了每种方法的具体操作步骤。

问题描述


使用SDK Manager更新时出现问题
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 http://dl-ssl.google.com/android/repository/addons_list-1.xml, reason: Connection to http://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时无法解析https://dl-ssl.google.com/android/eclipse


解决办法

由于某些众所周知又无法理解的原因,我们大陆使用Google的服务会出现种种问题,譬如Android开发也会出现阻碍。不过首先要说明的是一般情况下使用SDK Manager更新或者更新Eclipse的ADT插件是没有问题的,我以前也能正常更新,但是昨天不知道节点抽什么风,压根无法连接服务器,出现了上边的种种问题,下面说一下如果网络抽风的话应该如何解决问题。

第一种方法一劳永逸,直接配置VPN,但是现在想找个速度快又稳定还免费的VPN实在不易,尤其是更新SDK,以几kb/s的速度一个文件需要400多分钟,所以也就放弃了VPN。

另一种方法是使用http协议而不是https协议,因为https协议进行了加密处理,大陆因为无法审查,直接封死,而http协议则进行过滤处理,如果不访问乱七八糟的东西,更新个SDK还是没问题的。
在SDK Manager下Tools->Options打开了SDK Manager的Settings,选中“Force https://… sources to be fetched using http://…”,强制使用http协议。
而在更新ADT插件的时候则使用网址http://dl-ssl.google.com/android/eclipse,而不是https://dl-ssl.google.com/android/eclipse,这个在官方开发文档里也有介绍。
但是昨天的情况就是使用http协议也无法访问。

再说一个比较麻烦的方法,就是直接打开
https://dl-ssl.google.com/android/repository/addons_list.xml
https://dl-ssl.google.com/android/repository/repository.xml
https://dl-ssl.google.com/android/repository/addon.xml
这几个文件,找到你要下载的文件名,直接用迅雷下载,ADT可以直接在官网下载ADT包进行安装。具体方法自己搜索。

最好的方法还是改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协议,就可以正常的进行更新了。
或者也可以什么都不做,过上一两天可能会恢复正常。

下边贴上使用Google各种服务在修改hosts文件时需要添加的内容。

 

#Hosts文件开始,这句不需要复制

#Google Service
#Chrome 网上应用
203.208.46.146 chrome.google.com
203.208.46.146 clients0.google.com
203.208.46.146 clients1.google.com
203.208.46.146 clients2.google.com
203.208.46.146 clients3.google.com
203.208.46.146 clients4.google.com
203.208.46.146 www.googleusercontent.com
203.208.46.146 lh0.googleusercontent.com
203.208.46.146 lh1.googleusercontent.com
203.208.46.146 lh2.googleusercontent.com
203.208.46.146 lh3.googleusercontent.com
203.208.46.146 lh4.googleusercontent.com
203.208.46.146 lh5.googleusercontent.com
203.208.46.146 lh6.googleusercontent.com
203.208.46.146 clients1.googleusercontent.com
203.208.46.146 clients2.googleusercontent.com

#网页快照
203.208.46.146 webcache.googleusercontent.com

#Google SSL
203.208.46.146 encrypted.google.com
203.208.46.146 encrypted.google.com.hk

#Google Docs
203.208.46.146 docs.google.com
203.208.46.146 docs0.google.com
203.208.46.146 docs1.google.com
203.208.46.146 docs2.google.com
203.208.46.146 docs3.google.com
203.208.46.146 spreadsheets.google.com
203.208.46.146 spreadsheets0.google.com
203.208.46.146 spreadsheets1.google.com
203.208.46.146 spreadsheets2.google.com
203.208.46.146 spreadsheets3.google.com

#Gmail
203.208.46.146 mail.google.com
203.208.46.146 chatenabled.mail.google.com #Gmail中Gtalk聊天服务

#Google 搜索
203.208.46.146 www.google.com

#Google preview
203.208.46.146 www.googlepreview.com

#Google 翻译
203.208.46.146 translate.google.com
203.208.46.146 translate.googleapis.com

#Google 搜索建议(IE9)
203.208.46.146 clients5.google.com

#Google Code
203.208.46.146 code.google.com

#Picasa 网络相册
203.208.46.146 picasaweb.google.com
203.208.46.146 lh0.ggpht.com
203.208.46.146 lh1.ggpht.com
203.208.46.146 lh2.ggpht.com
203.208.46.146 lh3.ggpht.com
203.208.46.146 lh4.ggpht.com
203.208.46.146 lh5.ggpht.com
203.208.46.146 lh6.ggpht.com
203.208.46.146 lh7.ggpht.com
203.208.46.146 lh8.ggpht.com
203.208.46.146 lh8.ggpht.com
203.208.46.146 lh9.ggpht.com
203.208.46.146 lh6.google.com

#Google 个人资料
203.208.46.146 profiles.google.com
203.208.46.146 browsersync.google.com

#Google+
203.208.46.146 talkgadget.google.com #Google+中的聊天服务
203.208.46.146 ssl.gstatic.com
203.208.46.146 images-pos-opensocial.googleusercontent.com
203.208.46.146 images1-focus-opensocial.googleusercontent.com
203.208.46.146 images2-focus-opensocial.googleusercontent.com
203.208.46.146 images3-focus-opensocial.googleusercontent.com
203.208.46.146 images4-focus-opensocial.googleusercontent.com
203.208.46.146 images5-focus-opensocial.googleusercontent.com
203.208.46.146 images6-focus-opensocial.googleusercontent.com
203.208.46.146 plus.google.com

#Download 下载
203.208.46.146 dl.google.com
203.208.46.146 dl-ssl.google.com

#Groups
203.208.46.146 groups.google.com

#Google URL Shortener
203.208.46.146 goo.gl

#Google App Engine
203.208.46.146 appengine.google.com

#Android Developer

74.125.113.121 developer.android.com

#Hosts文件结束,这句不需要复制

 

//本人使用最后一种方法,把上面的hosts文件改了就好了(如果是win7\8的话会涉及管理员权限,不允许直接修改hosts文件,把此文件复制到其他盘,修改完毕后,覆盖一下就好了),不过我是在成功配置goAgent的情况下弄的,不知道不翻的话可不可以。

PS:本人比较笨,我相信应该也有跟我一样的,不知道如何设置https为htts的。

在SDK Mangager下Tools->Options勾中Force https://... sources to be fetched using http://...

就可以了

 

本文转自新浪博客:点击打开链接

http://blog.sina.com.cn/s/blog_4a94a0db0100y4h7.html

PS:之前写过一片一模一样的文章了,但是突然被删除了,客服的回复是涉及到翻TNND墙了,我这是一篇技术文章好不好0.0而且是为了帮助别人特意整理了一遍的好不好?我的使用方法都写进去了有木有?如果这次再被删除,我特么就直接把原文链接贴上就不管了,擦了

上述内容是一个 **robots.txt** 文件中声明的多个 Sitemap 索引文件(Sitemap Index)的示例,用于指导搜索引擎爬虫如何发现和抓取网站上大量的网页链接。这些 Sitemap 通常用于大型网站(如 eBay),以便更高效地管理成千上万甚至数百万个 URL。 每个 `Sitemap:` 行指向一个 **Sitemap 索引文件**,该索引文件本身不直接列出所有页面 URL,而是引用其他子 Sitemap 文件(例如按类别、类型或分片划分)。下面是对每一行的解释: --- ### 各类 Sitemap 的含义(基于命名推测): ```txt # AUCTION Sitemaps Sitemap: https://www.ebay.com/lst/AUCTION-0-index.xml ``` - **AUCTION**: 拍卖类商品页面。 - 这个索引文件可能包含所有以“拍卖”形式出售的商品列表页或详情页。 ```txt # BROWSE Sitemaps Sitemap: https://www.ebay.com/lst/BROWSE-0-index.xml ``` - **BROWSE**: 浏览类页面,用户通过分类导航访问的页面(如“电子产品 > 手机 > iPhone”)。 - 帮助搜索引擎抓取站点结构中的目录层级。 ```txt # KWSRP Sitemaps Sitemap: https://www.ebay.com/lst/KWSRP-0-index.xml ``` - **KWSRP**: Keyword Search Results Page(关键词搜索结果页)。 - 包含用户搜索某些关键词后生成的结果页面 URL- 对 SEO 很重要,因为很多流量来自长尾关键词。 ```txt # NGS Sitemaps Sitemap: https://www.ebay.com/lst/NGS-0-index.xml ``` - **NGS**: 可能是 Next Generation Search 或内部系统代号。 - 与搜索相关的动态页面或新架构下的搜索结果页。 ```txt # PRP Sitemaps Sitemap: https://www.ebay.com/lst/PRP-0-index.xml ``` - **PRP**: Product Result Page 或 Personalized Result Page。 - 展示商品结果的标准化页面,可能是推荐或非搜索入口进入的商品集合页。 ```txt # VIDEO Sitemaps Sitemap: https://www.ebay.com/lst/VIDEO-0-index.xml ``` - 包含带有视频内容的商品页面或独立视频页面。 - 有助于 Google 视频搜索收录。 ```txt # VIS Sitemaps Sitemap: https://www.ebay.com/lst/VIS-0-index.xml ``` - **VIS**: 可能指 Visual Search(视觉搜索)相关页面。 - 或者是 View Item Single(单个商品查看页)的缩写。 - 也可能与图像丰富的商品展示有关。 --- ### 实际使用方式(技术角度) 这些 `.xml` 文件是 **Sitemap Index 文件**,其内部结构类似于: ```xml <?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap> <loc>https://www.ebay.com/lst/AUCTION-0-0.xml</loc> <lastmod>2025-04-01T00:00:00Z</lastmod> </sitemap> <sitemap> <loc>https://www.ebay.com/lst/AUCTION-0-1.xml</loc> <lastmod>2025-04-01T00:05:00Z</lastmod> </sitemap> </sitemapindex> ``` 而每个子 Sitemap 文件(如 `AUCTION-0-0.xml`)则真正列出具体的 URL: ```xml <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>https://www.ebay.com/itm/123456789</loc> <lastmod>2025-04-01</lastmod> <changefreq>daily</changefreq> <priority>0.8</priority> </url> </urlset> ``` --- ### 如何下载并解析这些 Sitemap? 你可以使用 Python 脚本自动获取并解析它们: ```python import requests from xml.etree import ElementTree as ET from urllib.parse import urljoin def fetch_sitemap_index(sitemap_url): response = requests.get(sitemap_url) response.raise_for_status() root = ET.fromstring(response.content) namespaces = {'sm': 'http://www.sitemaps.org/schemas/sitemap/0.9'} sub_sitemaps = [] for sitemap in root.findall('sm:sitemap', namespaces): loc = sitemap.find('sm:loc', namespaces).text sub_sitemaps.append(loc) return sub_sitemaps def fetch_urls_from_sitemap(sitemap_url): response = requests.get(sitemap_url) response.raise_for_status() root = ET.fromstring(response.content) namespaces = {'sm': 'http://www.sitemaps.org/schemas/sitemap/0.9'} urls = [] for url in root.findall('sm:url', namespaces): loc = url.find('sm:loc', namespaces).text urls.append(loc) return urls # 示例:抓取 AUCTION 类型的所有子 Sitemap 中的前两个 URL 列表 index_url = "https://www.ebay.com/lst/AUCTION-0-index.xml" sub_sitemaps = fetch_sitemap_index(index_url) all_urls = [] for submap in sub_sitemaps[:2]: # 只取前两个测试 print(f"Fetching from {submap}...") urls = fetch_urls_from_sitemap(submap) all_urls.extend(urls) print(f"Found {len(urls)} URLs") print(f"Total URLs collected: {len(all_urls)}") ``` > ⚠️ 注意:eBay 可能会对频繁请求进行限流,请遵守 `robots.txt` 和合理延迟。 --- ### 为什么需要这么多 Sitemap? 大型电商平台 URL 数量可达数十亿,因此必须拆分: - 按功能模块拆分(搜索、浏览、拍卖等) - 每个 Sitemap 文件最多只能有 50,000 个 URL 或 50MB 大小 - 使用索引文件统一管理 --- ### 在 robots.txt 中的作用 Googlebot 和其他搜索引擎会优先读取网站根目录下的 `robots.txt`,然后根据其中的 `Sitemap:` 指令找到所有索引文件,进而递归抓取全部页面。 --- ### 相关工具推荐 - [Google Search Console](https://search.google.com/search-console/) - Screaming Frog(支持导入 Sitemap) - Python + `requests` + `lxml` 自动化分析 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值