When attempting to build for Android and using a version of the Android build tools version 31 or higher, this error may appear and cause the build to fail:
Installed Build Tools revision 32.0.0 is corrupted. Remove and install again using the SDK Manager.
Removing and reinstalling the Android SDK version will not resolve this error. This error is due to a packaging mistake with the Android SDK.
To resolve on Windows OS:
a. Navigate to the build tools folder in the Android SDK installation home folder:
[Android SDK home] / build-tools / 32.0.0
b. There is a file named d8.bat. Rename this file to dx.bat.
c. Navigate to the /lib subfolder.
d. There is a file named d8.jar. Rename this file to dx.jar.
e. Re-run the build for Android.
To resolve on MacOS:
a. Navigate to the build tools folder in the Android SDK installation home folder:
[Android SDK home] / build-tools / 32.0.0
b. There is a file named d8. Rename this file to dx.
c. Navigate to the /lib subfolder.
d. There is a file named d8.jar. Rename this file to dx.jar.
e. Re-run the build for Android.
This issue and resolution are described in the following Stack Overflow post:
https://stackoverflow.com/questions/68387270/android-studio-error-installed-build-tools-revision-31-0-0-is-corrupted