Android

Fix: “Could not read workspace metadata” / metadata.bin Missing Error in Android Studio

If you’re working on an Android or Flutter project, you may suddenly encounter a Gradle sync failure like this:

FAILURE: Build failed with an exception.

Could not read workspace metadata from
C:\Users\<username>\.gradle\caches\8.13\transforms\...

metadata.bin (The system cannot find the file specified)

At first glance, it looks like something is wrong with your project. Fortunately, this error is usually caused by a corrupted local Gradle cache and is very easy to fix.

Why Does This Happen?

Gradle stores downloaded dependencies and transformed artifacts inside the local cache.

During a build or Gradle sync, it creates metadata files such as metadata.bin to keep track of cached artifacts.

If Android Studio or the Gradle daemon is interrupted while writing these files, the cache can become inconsistent.

Common reasons include:

  • Force closing Android Studio
  • Windows restarting during a Gradle sync
  • Power failure
  • Cancelling a build
  • System crash
  • Antivirus temporarily locking or removing cache files

In my case, Android Studio was interrupted during a Gradle operation, which left the cache in an incomplete state.

Error Symptoms

You may see one or more of the following errors:

Could not read workspace metadata
metadata.bin (The system cannot find the file specified)
Build failed with an exception.

The project itself is usually fine—the issue exists only in your local Gradle cache.

Solution

Step 1: Close Android Studio

Make sure Android Studio is completely closed.

Step 2: Stop Gradle

Open Command Prompt and run:

gradlew --stop

or

gradle --stop

Step 3: Delete the Corrupted Cache

Delete the Gradle cache folder mentioned in the error.

For example:

C:\Users\<username>\.gradle\caches\8.13

If you prefer, you can delete only the transforms folder:

C:\Users\<username>\.gradle\caches\8.13\transforms

Do not worry—Gradle will recreate these files automatically.

Step 4: Reopen Android Studio

Open the project again.

Run:

  • Sync Project with Gradle Files, or
  • Build Project

Gradle will download and regenerate the missing cache.

Why This Fix Works

The missing metadata.bin file is part of Gradle’s internal cache.

When the cache becomes corrupted, Gradle continues trying to read it, resulting in the sync failure.

Deleting the corrupted cache forces Gradle to rebuild everything from scratch, which resolves the issue.

How to Prevent It

Although this issue cannot always be avoided, you can reduce the chances by:

  • Letting Gradle Sync finish before closing Android Studio
  • Avoiding force-closing Android Studio or Java processes
  • Avoiding system shutdowns during builds
  • Keeping sufficient free disk space
  • Excluding the .gradle directory from antivirus scans (if allowed by your organization’s security policy)

Final Thoughts

If you encounter an error mentioning:

  • metadata.bin
  • Could not read workspace metadata
  • transforms
  • workspace metadata

don’t panic.

In most cases, your project code is perfectly fine. The issue is simply a corrupted Gradle cache, and deleting the affected cache folder is the quickest and safest solution.

Hopefully, this saves you some debugging time. Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *