Table of contents

Android Studio error "Installed Build Tools revision 31.0.0 is corrupted"

Android Oct 16, 2021 Viewed 591 Comments 0

Issue

I recently upgraded the build version of the Android project, as follows:

buildscript {
    ext {
        supportLibVersion = "31.0.0"
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
    }
}

But there was an error saying:

Android Studio error "Installed Build Tools revision 31.0.0 is corrupted"

And I clicked 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. But after recompiling, I still got the same error.

Solution

The main problem is the two files missing in SDK build tool 31 that are:

  1. dx.bat
  2. dx.jar

The solution is that these files are named d8 in the file location so changing their name to dx will solve the error.

The steps are below.

For Windows

  1. Go to the location

     "C:\Users\user\AppData\Local\Android\Sdk\build-tools\31.0.0"​
  2. Find a file named d8.bat. This is a Windows batch file.
  3. Rename d8.bat to dx.bat.
  4. In the folder lib ("C:\Users\user\AppData\Local\Android\Sdk\build-tools\31.0.0\lib")
  5. Rename d8.jar to dx.jar

For macOS or Linux

Run the following command in the terminal:

# 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
Updated Oct 17, 2021