问题描述
我使用的是 Android Studio 4.2.2.我创建了一个新项目,但没有在启动代码中添加任何内容,每当我单击构建或运行时,我都会收到此错误:
I'm on Android Studio 4.2.2. I created a new project and haven't added anything to the starter code and whenever I click build or run, I get this error:
安装的构建工具修订版 31.0.0 已损坏.使用 SDK 管理器删除并重新安装.
我查看了其他帖子的建议,但这些解决方案都没有奏效.这是我尝试过的:
I've looked at other posts' suggestions, but neither of those solutions worked. Here's what I've tried:
- SDK Manager → SDK Tools → 勾选显示包详细信息",取消勾选 31.0.0,然后点击应用";→ 卸载 31.0.0 → 检查 31.0.0 并重新安装
- 在 SDK Manager 中,取消选择 31.0.0 并尝试安装旧版本(例如,我尝试过 30.0.3)并更新buildToolsVersion";在 build.gradle 到已安装的版本
- 转到项目结构 → 属性并确认为构建工具版本"选择了 31.0.0;和编译后的 SDK 版本"
- 手动删除 build-tools 文件夹中的东西;即,
rm -rf/path/to/android/sdk/build-tools/31.0.0
(它不像其他一些帖子描述的那样以-rc"结尾) - 重启 Android Studio
- 重新安装 Android Studio
- SDK Manager → SDK Tools → check "Show package details", uncheck 31.0.0, and click "Apply" → Uninstall 31.0.0 → check 31.0.0 and reinstall it
- In SDK Manager, deselect 31.0.0 and try installing an older version (e.g., I've tried 30.0.3) and update "buildToolsVersion" in build.gradle to the installed version
- Went to Project Structure → Properties and verified that 31.0.0 is selected for "Build Tools Version" and "Compiled SDK Version"
- Manually remove the stuff in the build-tools folder; i.e.,
rm -rf /path/to/android/sdk/build-tools/31.0.0
(it doesn't end in "-rc" like some other posts have described) - Restart Android Studio
- Reinstall Android Studio
我是一个 Android 菜鸟,只是想建立一个 hello world 项目,这真的不应该这么难.
I'm an Android noob just trying to set up a hello world project, and it really shouldn't be this hard.
推荐答案
遇到了同样的问题,修改了几行就解决了.
The same problem was encountered and solved with a few line changes.
检查项目代码面板,然后转到Gradle Scripts → build.gradle 文件,
Check the Project code panel, and go to Gradle Scripts → build.gradle file,
- 将三个位置从 31 改为 30:compileSdkVersion、buildToolsVersion 和 targetSdkVersion
- 您会注意到修改后的线路上发生了灯泡撞击.单击并选择同步 [到版本 30].Android Studio 将自动下载 BuildTool V30 并更改项目设置.
现在运行应用程序.它对我有用.
Now run the app. It works for me.
这篇关于Android Studio 错误“已安装的构建工具修订版 31.0.0 已损坏"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!