android studio first run : unable to sccess android sdk add-on list

这是 Android Studio 首次运行时常见的 SDK 访问问题。以下是完整的解决方案:

🔧 主要原因

  • 网络连接问题(特别是国内用户)
  • 代理配置不正确
  • 防火墙/杀毒软件阻止
  • hosts 文件问题

📝 解决方案

方案1:修改 hosts 文件(最常用)

  1. 打开 hosts 文件:

    • Windows : C:\Windows\System32\drivers\etc\hosts
    • macOS/Linux : /etc/hosts
  2. 在文件末尾添加以下内容:

    Google services

    203.208.40.66 dl.google.com
    203.208.40.66 dl-ssl.google.com
    64.233.162.83 www.googleapis.com
    64.233.162.83 android.googleapis.com
    64.233.162.83 www.google.com

    备用地址(如果上面不行)

    203.208.41.66 dl.google.com
    203.208.41.66 dl-ssl.google.com

  3. 保存文件(可能需要管理员权限)

  4. 刷新 DNS 缓存:

    bash 复制代码
    # Windows
    ipconfig /flushdns
    
    # macOS
    sudo dscacheutil -flushcache
    
    # Linux
    sudo systemctl restart nscd

方案2:配置 Android Studio 代理

如果方案1无效,尝试设置代理:

  1. 在首次运行界面点击 Cancel 跳过 SDK 下载

  2. 进入主界面后:

    • File → Settings (Windows/Linux)
    • Android Studio → Preferences (macOS)
  3. 找到 Appearance & Behavior → System Settings → HTTP Proxy

  4. 选择 Auto-detect proxy settings 或手动设置:

    复制代码
    HTTP: http://127.0.0.1:1080  # 你的代理地址
    HTTPS: http://127.0.0.1:1080

方案3:离线安装 SDK

  1. 从其他渠道下载 SDK:

  2. 解压到 Android Studio 目录:

    复制代码
    Windows: C:\Users\你的用户名\AppData\Local\Android\Sdk
    macOS: ~/Library/Android/sdk
    Linux: ~/Android/Sdk
  3. 重新启动 Android Studio

方案4:完全跳过首次设置

  1. 完全退出 Android Studio

  2. 删除配置文件:

    bash 复制代码
    # Windows
    del %USERPROFILE%\.android\repositories.cfg
    del %USERPROFILE%\.AndroidStudio*\config\options\updates.xml
    
    # macOS/Linux
    rm ~/.android/repositories.cfg
    rm ~/.AndroidStudio*/config/options/updates.xml
  3. 编辑 idea.properties 文件(在 Android Studio 安装目录的 bin 文件夹中):

    复制代码
    disable.android.first.run=true

方案5:命令行安装(推荐)

  1. 打开终端或命令提示符

  2. 使用 sdkmanager 手动下载:

    bash 复制代码
    # 先更新 sdkmanager
    cd %ANDROID_HOME%\tools\bin
    sdkmanager --update
    
    # 安装必要组件
    sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.0"
    sdkmanager "extras;google;m2repository"
    sdkmanager "extras;android;m2repository"

快速应急方案

如果急需使用,可以:

  1. 点击 Cancel 跳过设置

  2. 创建新项目时选择 Empty Activity

  3. 在项目级的 build.gradle 中添加阿里云镜像:

    gradle 复制代码
    buildscript {
        repositories {
            maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/jcenter' }
        }
    }
    
    allprojects {
        repositories {
            maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/jcenter' }
        }
    }

🛠️ 检查网络连接

在 Android Studio 终端测试:

bash 复制代码
# 测试 Google 连接
ping dl.google.com
curl -v https://dl.google.com/android/repository/repository2-1.xml

# 测试是否被防火墙阻止
telnet dl.google.com 443

💡 预防措施

  1. 使用稳定的网络(避免公共 Wi-Fi)
  2. 关闭 VPN/代理 再试一次
  3. 禁用防火墙/杀毒软件 临时测试
  4. 以管理员身份运行 Android Studio

📞 如果所有方法都失败

  1. 检查 Android Studio 版本(建议使用最新稳定版)
  2. 尝试使用 Android Studio 预览版
  3. 在官方 Issue Tracker 查找解决方案:
    https://issuetracker.google.com/issues?q=componentid:192708

选择最适合你情况的方案,通常方案1(修改hosts) 对国内用户最有效!

相关推荐
limuyang26 小时前
PDF Viewer KMP(基于 chrome 的 PDFium 内核)
android·kotlin
心平气和量大福大10 小时前
android-控件-搜索框SearchView
android·gitee
2601_9621771310 小时前
【MySQL篇】聚合查询,联合查询
android·java·mysql
壮哥_icon10 小时前
【Android】批量 VectorDrawable 动态分别修改 fillColor 和 strokeColor 的踩坑与终极解决方案
android
齐天qaq11 小时前
Android 系统 APK 分区与权限
android
心平气和量大福大11 小时前
android-控件-多选框CheckBox
android·gitee
我命由我1234512 小时前
Linux - Linux/POSIX 路径斜杠折叠规则
linux·运维·服务器·android studio·android jetpack·android-studio·android runtime
pengyu13 小时前
【Kotlin 协程修仙录 · 大乘境 · 初阶】 | 跳出三界:协程在 KMP 与后端开发中的跨平台之道
android·kotlin
XiaoLeisj13 小时前
Android Memory Profiler:堆内存指标、内存抖动与泄漏定位
android·性能优化·内存抖动·内存泄露·memory profiler