更新SDK失败解决办法(Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-1.xml)

本文介绍了一种解决Android SDK下载失败的方法,通过修改hosts文件指向正确的dl-ssl.google.com IP地址,确保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来编辑。
你看到的这些警告信息: ```text W: Failed to fetch http://rdsource.tp-link.com/ubuntu/dists/xenial/InRelease Could not resolve 'rdsource.tp-link.com' ... W: Some index files failed to download. They have been ignored, or old ones used instead. ``` 说明你的系统在执行 `apt update` 时,**试图从一个不存在或无法访问的软件源地址下载更新列表,但失败了**。 --- ## 🔍 错误原因分析 ### ❌ 问题根源: > **`rdsource.tp-link.com` 这个域名已经无法解析(DNS 找不到)或服务器已关闭。** 这个域名是 **TP-Link 内部研发使用的私有源(intranet 源)**,通常用于公司内部网络中的镜像服务。它**不是公网可访问的地址**,只在 TP-Link 公司局域网内可用。 你现在是在外部网络(家庭、学校、云服务器等),自然无法连接到这个内网地址。 --- ### 📦 这些源是怎么来的? 这类非标准源通常是以下几种情况导致的: | 原因 | 说明 | |------|------| | ✅ 镜像由 TP-Link 内部人员制作 | 制作 Docker 镜像时没有清理 `/etc/apt/sources.list`,保留了他们公司的私有源 | | ✅ 使用了挂载的宿主机目录 | 启动容器时用 `-v /etc/apt:/etc/apt` 挂载了宿主机配置,带入了错误源 | | ✅ 构建镜像时未重置 sources.list | 在 `Dockerfile` 中安装完软件后没把源改回官方或公共镜像 | --- ## ✅ 解决方案:更换为可靠的公共软件源 你需要替换掉所有指向 `rdsource.tp-link.com` 的源,改为使用阿里云、清华、中科大等支持 Ubuntu 16.04 的镜像站。 --- ### ✅ 步骤 1:备份并修改软件源文件 ```bash # 备份原始文件(以防出错) sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak # 清空当前内容,并写入阿里云镜像源 cat > /etc/apt/sources.list << 'EOF' # Aliyun Mirror for Ubuntu 16.04 (xenial) deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse # 源码包(可选) deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse EOF ``` --- ### ✅ 步骤 2:更新软件包列表 ```bash sudo apt update ``` 你应该不会再看到 `rdsource.tp-link.com` 的错误,而且能正常获取更新--- ### ✅ 步骤 3:升级系统(可选) 如果还有安全补丁可以应用: ```bash sudo apt upgrade -y ``` --- ## 💡 补充建议 ### ⚠️ 关于 Ubuntu 16.04 EOL 的提醒 Ubuntu 16.04 已于 **2021 年 4 月结束常规支持**,目前只有通过 [Ubuntu Pro](https://ubuntu.com/pro) 提供的安全维护(ESM)。 这意味着即使你换成了阿里云源,部分更新可能仍然受限,除非你启用了 ESM。 👉 推荐长期项目迁移到 **Ubuntu 20.04 LTS 或 22.04 LTS**。 --- ### ✅ 如何避免未来再次出现此问题? #### 方法一:构建自己的干净镜像(推荐) 创建一个 `Dockerfile` 来自动化修复: ```Dockerfile FROM my-ubuntu:16.04-minimal # 更换为阿里云源 RUN echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse" > /etc/apt/sources.list && \ echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse" >> /etc/apt/sources.list && \ echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse" >> /etc/apt/sources.list && \ echo "deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" >> /etc/apt/sources.list # 更新 RUN apt update && apt upgrade -y # 安装常用工具(可选) RUN apt install -y curl wget git vim net-tools iproute2 python3 # 设置默认命令 CMD ["/bin/bash"] ``` 然后构建新镜像: ```bash docker build -t my-clean-ubuntu:16.04 . ``` 以后就用这个干净镜像启动容器,不再受私有源影响。 --- ## ✅ 总结 | 问题 | 原因 | 解决办法 | |------|------|-----------| | `Could not resolve 'rdsource.tp-link.com'` | 访问的是 TP-Link 内部私有源,公网不可达 | 替换为阿里云、清华等公共镜像源 | | 警告提示 “Failed to fetch” | APT 尝试拉取失效源 | 修改 `/etc/apt/sources.list` 文件 | | 安全风险 | Ubuntu 16.04 已 EOL | 尽快迁移到新版 Ubuntu | ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值