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

483 阅读1分钟

问题澄清

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:

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

解决方案

First of all, I face this issue in Android Studio 4.2.2 and you not need to downgrade the SDK build tool 31 to 30 or not to change compile SDK version.
The main problem is the two files missing in SDK build tool 31 that are
1.  *dx.bat*
1.  *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

Remember AppData is a hidden folder. Turn on hidden items to see the AppData folder.