Skip to content

Android Build Tools Revision Corrupted Error

Problem

When attempting to build or run a new Android project in Android Studio, you may encounter the error:

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

This issue typically occurs with Android Build Tools version 31.0.0 and prevents successful project compilation, even on simple "Hello, World!" projects.

Root Cause

The error occurs because Build Tools 31.0.0 is missing two critical files that Android Studio expects to find:

  1. dx.bat (Windows) or dx (macOS/Linux)
  2. dx.jar (in the lib subdirectory)

These files were intentionally removed from Android Build Tools 31+ as part of Google's transition from the DX tool to D8 for Dex compilation. However, some older versions of the Android Gradle Plugin (AGP) still expect these files to exist.

Solutions

The most future-proof solution is to update your project to use a compatible Android Gradle Plugin version that properly supports Build Tools 31+.

gradle
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.2" // or higher
        // For Kotlin projects:
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"
    }
}
gradle
plugins {
    id 'com.android.application'
    id 'kotlin-android' // if using Kotlin
}

android {
    compileSdk 31 // Modern syntax without buildToolsVersion
    // buildToolsVersion is no longer needed from AGP 3.1.0+

    defaultConfig {
        minSdk 21
        targetSdk 31
        // ... other config
    }
    // ... rest of configuration
}
properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

TIP

From Android Gradle Plugin 3.1.0+, you no longer need to explicitly specify buildToolsVersion - the plugin automatically uses the minimum required version.

Solution 2: File Renaming Workaround

If you cannot immediately upgrade your Gradle plugin, you can manually create the missing files by renaming the newer D8 equivalents:

Windows

  1. Navigate to your Android SDK build-tools directory:
    cmd
    cd %ANDROID_HOME%\build-tools\31.0.0
  2. Rename the files:
    cmd
    ren d8.bat dx.bat
    cd lib
    ren d8.jar dx.jar

macOS/Linux

Run these terminal commands:

bash
cd ~/Library/Android/sdk/build-tools/31.0.0 \
  && mv d8 dx \
  && cd lib \
  && mv d8.jar dx.jar

Instead of renaming, you can create symbolic links:

Windows:

cmd
mklink %ANDROID_HOME%\build-tools\31.0.0\dx.bat %ANDROID_HOME%\build-tools\31.0.0\d8.bat
mklink %ANDROID_HOME%\build-tools\31.0.0\lib\dx.jar %ANDROID_HOME%\build-tools\31.0.0\lib\d8.jar

macOS/Linux:

bash
ln -s ~/Library/Android/sdk/build-tools/31.0.0/d8 ~/Library/Android/sdk/build-tools/31.0.0/dx
ln -s ~/Library/Android/sdk/build-tools/31.0.0/lib/d8.jar ~/Library/Android/sdk/build-tools/31.0.0/lib/dx.jar

Solution 3: Downgrade Build Tools Version

If you prefer to use an older, stable version of Build Tools:

  1. Open SDK Manager in Android Studio
  2. Go to SDK Tools tab
  3. Check "Show package details"
  4. Uncheck version 31.0.0
  5. Check version 30.0.3 (or another stable version)
  6. Click Apply to install

Then update your build.gradle file:

gradle
android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"
    // ... rest of configuration
}

Solution 4: Complete Reinstallation

Sometimes a complete reinstallation resolves the issue:

  1. Uninstall Build Tools 31.0.0 from SDK Manager
  2. Manually delete the directory: %ANDROID_HOME%/build-tools/31.0.0
  3. Restart Android Studio
  4. Reinstall Build Tools 31.0.0 from SDK Manager

CI/CD Pipeline Fixes

For automated build environments like CircleCI or Azure DevOps, add these steps to your pipeline:

yaml
# For CircleCI
- run:
    name: Fix missing DX files in Build Tools
    command: |
      cd $ANDROID_HOME/build-tools/31.0.0 && mv d8 dx && cd lib && mv d8.jar dx.jar

# For Azure DevOps
- bash: |
    $ANDROID_HOME/tools/bin/sdkmanager --uninstall 'build-tools;31.0.0'

Additional Considerations

  • Unity Developers: If working with Unity, you may need to uncheck "Split Application Binary" in player settings or customize Gradle templates
  • Licensing Library: Ensure "Google Play Licensing Library" is installed in SDK Manager
  • Annotation Conflicts: Add exclusion rules if you encounter annotation conflicts:
gradle
configurations {
    compile.exclude group: 'com.intellij', module: 'annotations'
    implementation.exclude group: 'com.intellij', module: 'annotations'
}

Prevention

To avoid similar issues in the future:

  1. Keep Android Studio and plugins updated
  2. Use the latest stable versions of Build Tools
  3. Regularly update your project's Gradle wrapper and Android Gradle Plugin
  4. Consider using the modern Gradle DSL without explicit buildToolsVersion

WARNING

The file renaming workaround is a temporary solution. Plan to migrate to updated Android Gradle Plugin versions that properly support newer Build Tools.

By implementing these solutions, you should be able to resolve the "Build Tools revision is corrupted" error and continue with your Android development.