我使用的是 Android Studio 4.2.2.我创建了一个新项目,但没有在启动代码中添加任何内容,每当我单击 build 或 run 时,都会收到此错误:
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 管理器删除并重新安装.
Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
我查看了其他帖子的建议,但这些解决方案都没有奏效.这是我尝试过的:
I've looked at other posts' suggestions, but neither of those solutions worked. Here's what I've tried:
rm -rf/path/to/android/sdk/build-tools/31.0.0
(它不像其他一些帖子所描述的那样以-rc"结尾)rm -rf /path/to/android/sdk/build-tools/31.0.0
(it doesn't end in "-rc" like some other posts have described)我是一个 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.
首先,我在Android Studio 4.2.2中遇到过这个问题,你不需要将SDK构建工具从31降级到30或更改编译SDK版本.
First of all, I faced this issue in Android Studio 4.2.2 and you do not need to downgrade the SDK build tool from 31 to 30 or change compile SDK version.
主要问题是 SDK 构建工具 31 中缺少的两个文件是:
The main problem is the two files missing in SDK build tool 31 that are:
解决方案是这些文件在文件位置命名为 d8,因此将其名称更改为 dx 即可解决错误.
The solution is that these files are named d8 in the file location so changing their name to dx will solve the error.
步骤如下.
前往该地点
go to the location
"C:UsersuserAppDataLocalAndroidSdkuild-tools31.0.0"
找到一个名为 d8.bat 的文件.这是一个 Windows 批处理文件.
find a file named d8.bat. This is a Windows batch file.
将 d8.bat 重命名为 dx.bat.
rename d8.bat to dx.bat.
在文件夹 lib(C:UsersuserAppDataLocalAndroidSdkuild-tools31.0.0lib")中
in the folder lib ("C:UsersuserAppDataLocalAndroidSdkuild-tools31.0.0lib")
将 d8.jar 重命名为 dx.jar
rename d8.jar to dx.jar
记住 AppData 是一个隐藏文件夹.打开隐藏项以查看 AppData 文件夹.
Remember AppData is a hidden folder. Turn on hidden items to see the AppData folder.
# change below to your Android SDK path
cd ~/Library/Android/sdk/build-tools/31.0.0
&& mv d8 dx
&& cd lib
&& mv d8.jar dx.jar
现在运行您的项目.
这篇关于Android Studio 错误“安装的构建工具修订版 31.0.0 已损坏"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!