Android Studio 错误“安装的构建工具修订版 31.0.0 已损坏"

Android Studio error quot;Installed Build Tools revision 31.0.0 is corruptedquot;(Android Studio 错误“安装的构建工具修订版 31.0.0 已损坏)
本文介绍了Android Studio 错误“安装的构建工具修订版 31.0.0 已损坏"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我使用的是 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:

  1. SDK Manager → SDK Tools → 勾选Show package details",取消勾选 31.0.0,点击Apply";→ 卸载 31.0.0 → 检查 31.0.0 并重新安装
  2. 在 SDK 管理器中,取消选择 31.0.0 并尝试安装旧版本(例如,我尝试过 30.0.3)并更新buildToolsVersion".在 build.gradle 到安装的版本
  3. 前往Project StructureProperties 并确认为Build Tools Version"选择了 31.0.0.和编译的 SDK 版本"
  4. 手动删除 build-tools 文件夹中的东西;即,rm -rf/path/to/android/sdk/build-tools/31.0.0(它不像其他一些帖子所描述的那样以-rc"结尾)
  5. 重启 Android Studio
  6. 重新安装 Android Studio
  1. 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
  2. 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
  3. Went to Project StructureProperties and verified that 31.0.0 is selected for "Build Tools Version" and "Compiled SDK Version"
  4. 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)
  5. Restart Android Studio
  6. 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.

推荐答案

首先,我在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:

  1. dx.bat
  2. dx.jar

解决方案是这些文件在文件位置命名为 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.

步骤如下.

  1. 前往该地点

  1. 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 已损坏"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

    本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!
  • 相关文档推荐

    How To Create a Rotating Wheel Control?(如何创建转轮控件?)
    How to avoid restarting activity when orientation changes on Android(如何在 Android 上的方向更改时避免重新启动活动)
    Screen orientation lock(屏幕方向锁定)
    Strange behavior with android orientation sensor(android方向传感器的奇怪行为)
    Android: Rotate image in imageview by an angle(Android:将imageview中的图像旋转一个角度)
    Activity restart on rotation Android(旋转Android上的活动重启)