Issue
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.
I've looked at other posts' suggestions, but neither of those solutions worked. Here's what I've tried:
- 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
- In SDK Manager, deselect 31.0.0 and try installing an older version (e.g., I've tried 30.0.3) and update "buildToolsVersion" in build.gradle to the installed version
- Went to Project Structure → Properties and verified that 31.0.0 is selected for "Build Tools Version" and "Compiled SDK Version"
- Manually remove the stuff in the build-tools folder; i.e.,
rm -rf /path/to/android/sdk/build-tools/31.0.0
(it doesn't end in "-rc" like some other posts have described) - Restart Android Studio
- Reinstall Android Studio
I'm an Android noob just trying to set up a hello world project, and it really shouldn't be this hard.
Solution
First of all, I faced this issue in Android Studio 4.2.2 and you do not need to downgrade the SDK build tool from 31 to 30 or change compile SDK version.
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
Remember AppData is a hidden folder. Turn on hidden items to see the AppData folder.
For macOS or Linux
# 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
Now run your project.
Answered By - user16475264
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.