Android SDK 系统镜像安装问题修复
问题描述
在 Windows 上安装 Android SDK 系统镜像时报错:
An error occurred while preparing SDK package Google Play Intel x86_64 Atom System Image: Not in GZIP format.
原因分析
- 网络问题导致下载的 zip 文件损坏(可能被代理/防火墙拦截返回了 HTML)
- SDK 路径与实际安装位置不一致
- 项目路径包含中文字符
解决步骤
1. 清除缓存(无效时跳过)
Remove-Item -Path "$env:USERPROFILE\.android\cache" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$env:LOCALAPPDATA\Android\Sdk\.temp" -Recurse -Force -ErrorAction SilentlyContinue
2. 手动下载系统镜像
浏览器直接下载:
https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-36_r07.zip
3. 解压到正确的 SDK 路径
根据 Android Studio 显示的 SDK Path 确定目标路径(我的是 D:\android-sdk-windows):
# 创建目录
New-Item -ItemType Directory -Path "D:\android-sdk-windows\system-images\android-36\google_apis_playstore" -Force
# 解压
Expand-Archive -Path "C:\Users\傅懿\Downloads\android\x86_64-36_r07 (2)\x86_64-36_r07.zip" -DestinationPath "D:\android-sdk-windows\system-images\android-36\google_apis_playstore" -Force
4. 修复目录嵌套问题
如果解压后出现 x86_64/x86_64 嵌套:
Move-Item -Path "D:\android-sdk-windows\system-images\android-36\google_apis_playstore\x86_64\x86_64\*" -Destination "D:\android-sdk-windows\system-images\android-36\google_apis_playstore\x86_64\" -Force
Remove-Item -Path "D:\android-sdk-windows\system-images\android-36\google_apis_playstore\x86_64\x86_64" -Recurse -Force
5. 解决中文路径问题
项目路径包含中文会导致构建失败,在 gradle.properties 添加:
android.overridePathCheck=true
6. 配置国内镜像加速
修改 settings.gradle.kts:
pluginManagement {
repositories {
maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin") }
maven { url = uri("https://maven.aliyun.com/repository/google") }
maven { url = uri("https://maven.aliyun.com/repository/public") }
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven { url = uri("https://maven.aliyun.com/repository/google") }
maven { url = uri("https://maven.aliyun.com/repository/public") }
google()
mavenCentral()
}
}
验证安装成功
Get-ChildItem "D:\android-sdk-windows\system-images\android-36\google_apis_playstore\x86_64"
应该看到 system.img、vendor.img、ramdisk.img 等文件。
相关链接
- Android Issue 95744 - 非 ASCII 路径问题
- 阿里云 Maven 镜像
创建时间:2025-12-29
标签:#Android #SDK #Windows #问题修复