解决Android SDK下载和更新失败的方法详解


最近刚换了电脑,开始搭建Android开发环境的时候,下载SDK总是会出现如下错误:

复制代码 代码如下:

Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-1.xml.


说dl-ssl.google.com在大陆被强了,解决方法就是修改C:\Windows\System32\drivers\etc\hosts文件。添加一行:

复制代码 代码如下:

74.125.237.1       dl-ssl.google.com

这里需要注意的是hosts文件是只读的,我们没有权限修改,需要我们将hosts文件复制到桌面或者其他地方,然后修改,代码如下:
复制代码 代码如下:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1       localhost
# ::1             localhost
//亲,就是增加这一句哦
74.125.237.1       dl-ssl.google.com


然后保存,复制修改后的hosts文件到C:\Windows\System32\drivers\etc 目录,替换文件就好!!!我们再次下载SDK的时候就会成功啦,如下图:

嘿嘿,大功告成啦!!!
PS:补充下,在mac或Linux中,hosts文件所在位置为/etc/hosts,可以使用sudo vim /etc/hosts来编辑。

其它网友的补充:

android sdk 下载后,通常需要更新sdk对应的平台的版本,但是当我们开始更新的时候,通常会提示“Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: hostname in certificate didn't match: <dl-ssl.google.com> != <www.google.com> OR <www.google.com>”这样的错误,从而导致无法进行android sdk的更新,这里提供了一种解决sdk更新的方法,希望对大家有用;

方便他人亦是方便自己,如果觉得还行就点下赞吧,这样可以帮助其他人更快的找到解决问题的方法;有疑问的也可留言哦, 谢谢!

视频和软件的百度云地址:http://pan.baidu.com/s/1o6sNDqy

工具/原料

win7 x64

android-sdk-windows r23

方法/步骤

1、下载服务器代理工具,上面的百度云地址里有,解压后(需要解压两次),安装,具体的可以参见百度云地址里的视频。

2、启动服务器代理工具“免费代理服务器”,如下:

3、打开 android sdk manager “"D:\Android\android-sdk-windows\SDK Manager.exe"”,会发现弹出如下的错误

4、打开 “android sdk manager->tools->Options...", 设置 服务器代理地址,服务器代理地址可以从服务器代理软件上查询得到,如下图:

5、重新打开”"D:\Android\android-sdk-windows\SDK Manager.exe"“, 运行效果如下:

6、android sdk 在更新的过程中会遇到更新失败的问题如图,重新点击安装就可以解决了

END

原作者:付科


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3