Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
Studio Version 4.2.1
Tried Reinstalling and removing previous versions Tried adding dx.jar and dx.bat from build-tools-30.0.3 (This is not a good solution even after adding it shows dx.jar file is not there)



Check the
buildToolsVersioninbuild.gradlefile. It should be same as which you have installed fromSDK Manager -> SDK Toolswhere you will findAndroid SDK Build-Tools 31.dxfile will be available at the location of sdkAndroid SDK dir\build-toolsand you will find31.0.0-rc3 (Open this folder and check manually if dx file is there or not). If all works fine then restart and rebuild the project.If
dxfile is not there then uninstall the build tools from Android Studio and reinstall it again from Android Studio.