Coding⏱️ 2 min read📅 2026-05-31

How to Fix: Error: Execution failed for task ':app:clean'. Unable to delete file

Error in Android Studio Gradle project rebuilding process due to unable to delete file exception.

Quick Answer: Try deleting the .idea folder and cleaning the project again, or use the 'Delete Cache' option from the Run menu.

The error you're experiencing is caused by the Android Studio Gradle project not being able to delete a file that was generated during the previous build process. This can happen when there are multiple versions of the same library or dependency in your project, causing conflicts.

🛑 Root Causes of the Error

  • Multiple versions of the same library or dependency in your project.

🔧 Proven Troubleshooting Steps

Method 1: Cleaning the Project Directory

  1. Step 1: Close Android Studio and navigate to the project directory in your terminal or command prompt.

Method 2: Deleting the .class Files

  1. Step 1: Open a terminal or command prompt in your project directory and run the following command to delete the .class files:
rm -rf app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars/classes.jar

🎯 Final Words

By following these steps, you should be able to resolve the error and rebuild your project successfully.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions