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

时间:2022-05-14 07:09:54

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

复制代码 代码如下:

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


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

 

说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的时候就会成功啦,如下图:

 

解决Android 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、启动服务器代理工具“免费代理服务器”,如下:

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

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

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

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

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

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

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

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

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

end

原作者:付科