Android Studio error "Installed Build Tools revision 31.0.0 is corrupted"
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:
- dx.bat
- 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
Go to the location
"C:\Users\user\AppData\Local\Android\Sdk\build-tools\31.0.0"
- Find a file named d8.bat. This is a Windows batch file.
- Rename d8.bat to dx.bat.
- In the folder lib ("C:\Users\user\AppData\Local\Android\Sdk\build-tools\31.0.0\lib")
- 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