xinli/xinli-App/安装BuildTools说明.md
2025-11-23 10:19:32 +08:00

82 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 安装 Android Build Tools 说明
## 问题
构建时提示:`Failed to find Build Tools revision 30.0.3`
## 解决方案
### 方法一:使用 Android Studio 安装(推荐,最简单)
1. **打开 Android Studio**
2. **打开项目**
3. **打开 SDK Manager**
- 点击工具栏的 `SDK Manager` 图标
- 或菜单:`Tools` → `SDK Manager`
4. **安装 Build Tools**
- 切换到 `SDK Tools` 标签页
- 勾选 `Android SDK Build-Tools`
- 确保版本 **30.0.3** 或更高已勾选
- 点击 `Apply` 开始安装
5. **等待安装完成**
6. **重新运行打包**
```bash
build-apk.bat
```
### 方法二:检查已安装的版本并使用
1. **运行检查脚本**
```bash
检查BuildTools.bat
```
这会显示你已安装的所有 Build Tools 版本
2. **修改 `app/build.gradle`**
找到 `buildToolsVersion` 这一行,改为你已安装的版本,例如:
```gradle
buildToolsVersion "29.0.3" // 使用你已安装的版本
```
### 方法三:使用命令行安装(需要网络)
如果你有 Android SDK 命令行工具,可以运行:
```bash
sdkmanager "build-tools;30.0.3"
```
但通常使用 Android Studio 更简单。
## 常见 Build Tools 版本
- **30.0.3** - 推荐(与 compileSdkVersion 30 匹配)
- **30.0.2**
- **30.0.1**
- **30.0.0**
- **29.0.3** - 如果 30.x 不可用,可以使用这个
## 验证安装
安装后Build Tools 应该位于:
```
C:\Users\Administrator\AppData\Local\Android\Sdk\build-tools\30.0.3\
```
## 注意事项
- 确保网络连接正常(如果需要下载)
- 如果网络受限,可能需要配置代理
- 安装完成后,重新运行 `build-apk.bat`
## 快速检查
运行以下命令检查 Build Tools 是否已安装:
```powershell
Test-Path "C:\Users\Administrator\AppData\Local\Android\Sdk\build-tools\30.0.3"
```
如果返回 `True`,说明已安装;如果返回 `False`,需要安装。