Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Gradle Build Failure Could not open proj class cache for build file

Writer Sebastian Wright
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'oscar'.
> Could not open proj class cache for build file '/Users/prakashv/dev/workspace/oscar-api/build.gradle' (/Users/prakashv/.gradle/caches/2.6/scripts/build_7o20dvaacd2xu3ci3o56uhd4f/proj). > Timeout waiting to lock proj class cache for build file '/Users/prakashv/dev/workspace/oscar-api/build.gradle' (/Users/prakashv/.gradle/caches/2.6/scripts/build_7o20dvaacd2xu3ci3o56uhd4f/proj). It is currently in use by another Gradle instance. Owner PID: unknown Our PID: 47991 Owner Operation: unknown Our operation: Initialize cache Lock file: /Users/prakashv/.gradle/caches/2.6/scripts/build_7o20dvaacd2xu3ci3o56uhd4f/proj/cache.properties.lock
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Any idea what the problem could be ? I am using gradle 2.6 and Java 1.8.0_60

3

18 Answers

To solve this I had to first kill the Java(TM) Platform SE binary process and then I was able to delete the whole /Users/<username>/.gradle/caches folder which allowed Gradle commands to work once again.

I believe this issue may have happened for me as a result of adding a new dependency to my build.gradle file through IntelliJ IDEA.

2

tl;dr: Try an older JDK


Deleting caches didn't work for me. Deleting the lock files didn't fix it either.

After switching to an older JDK I was able to build my project again.


Idea configured the project to use JDK 14 (preview) but that doesn't seem to work. I set the JDK to 13. Actually the dialogue said it was JDK 13 but somehow from the JDK 14 preview install. So I had to install an actual JDK 13.

What @Shriganesh Kolhe said on Apr 22 '17 at 18:12 is roughly 97.3% correct--just a missing \ in the path to navigate to. Corrected/clarified below.

What follows is a generalization of the process since we're all way past gradle release 2.14.1. (Today I'm at 4.1.) And this error will happen again to someone, some day at a higher gradle release.

(1) Locate the folder caches at the end of this path: C:\Users\your_user_name\.gradle\caches\. (For me, this was C:\Users\Dov\.gradle\caches\.)

(2) Find the folder whose name is the LARGEST release number SMALLER than the gradle release being installed. (For me, installing 4.1, this was 3.3.)

(3) For safety, copy the scripts and scripts-remapped folders to safe places.

(4) Then (no worries--you're backed up!) delete all the files in those folders.

(5) Finally build again.

(In the unlikely event that this causes errors, put the moved folders back in place. It worked great for me as outlined.)

Solution for me was fairly simple:

  • Go to the C:\Users\YOUR_USERNAME\.gradle\caches and locate the subfolder that is being complained about in your error message (e.g., 4.4).
  • Rename that folder (e.g., to 4.4_OLD).
  • Back in Android Studio, do Clean Project then Rebuild Project.

This will then generate a new subfolder (e.g., 4.4) in your caches directory and the build should complete successfully.

In my case syncing files using Android Studio helped!

I've fixed it on Windows.

Open the command prompt, change to the project directory, and clear the gradle cache using the following command.

gradlew clean

This worked for me.

I fixed this by increasing total heap size of the Gradle daemon and MetaSpace

org.gradle.jvmargs=-Xmx2048M -XX:MaxMetaspaceSize=512m

inside gradle.properties

1

navigate to C:\Users\user.gradle\caches\2.14.1

move the 'scripts' and 'scripts-remapped'folder to somewhere else. (just in case if something goes wrong)

then try to build again.

It works for me.

0

In my case, I have installed Java 19, The latest java version on my Mac Apple M1 chip. After downgrading it to version 17 my issue is fixed.

I use these commands to uninstall Java 19

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk[version].jdk

sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane

sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

sudo rm -rf ~/Library/Application\ Support/Oracle/Java

And download Java-17 from here

My problem solved by upgrading gradle. because I was using Java 17 but gladle version I was using didn't support it. Checking compatibility matrix for gradle would be useful. you can check it from Compatibility Matrix

You can also check this answer

1

go to location

"/Users/prakashv/.gradle/caches/2.6/scripts/build_7o20dvaacd2xu3ci3o56uhd4f/proj/" and remove cache.properties.lock file

go to the build folder its pointing and delete the " cacheproperties.lock " files if it shows again a different one this time , delete that too . In my case i did it 2 times .

1

hope my answer will help you. First you should enter the dir "/.gradle/cache/2.x/" and copy the file scripts and scripts-remapped. Then paste them to somewhere else in case of taking place something if you do next. Delete them from the dir "/.gradle/cache/2.x/" finally you should sync the gradle (if everything is OK, Congratulations ) (if not maybe you will find that it will be impossible to establish the initial state so you are supposed to delete the ideal.log(some tips will give you on the top right corner,you can find the path of the ideal.log))

1

check with jdk version, JDK 16 may causing the issue. You can try to install lower version. I have tried with 11 and 8 jdk and its working. And then rebuild your app.

I figured out something, if you are working on Flutter you can just open the build.gradle Open for Editing in Android Studio then wait for 3-5 minutes. Now try again to get the sha1 key (my case).

It can be JDK version issue try to reinstall it. This steps works for me

You also might want to check your JAVA_HOME variable, in my case I had set it to a different JDK version and my build was looking for 1.18. when I corrected the path and the build worked.

Came across this issue while using Android Gradle Plugin version 8.1.0. Every time I edited something on build.gradle file the error happened.

I checked my project's JDK version, which was at JDK 20.

What helped was to lower JDK Version on my project from JDK 20 to JDK 18.