The Android Studio will automatically download BuildTool V30 and change project settings. To Solve Installed Build Tools revision 31.0. 0 is corrupted. Remove and install again using the SDK Manager Error Just Check the Project code panel, and go to Gradle Scripts –> build.
Just uninstall it and download it again. How to download it in android studio. Re-install Android SDK and run your Android app. The problem has been fixed.
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:
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.
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.
# 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.
The same problem was encountered and solved with a few line changes.
Check the Project code panel, and go to Gradle Scripts → build.gradle file,
Now run the app. It works for me.
The point is not to downgrade target API level, but to build exactly for API level 31 to prepare and test an app for Android 12!
It looks like DX is removed from SDK in favor of D8.
It looks like that Android Gradle plugin 4.x is not aware of that.
At the moment I see only two solutions:
After changing these settings, it seems to work fine. I downloaded SDK version 30 from SDK Manager.
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.anurag.myapplication"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With