58

I just started using Android Studio 1.3 sdk 24 and it has worked fine until today. I get this error message about cache.properties and I delete that cache file but now I am getting this error message:

Error:C:\Users\user1.gradle\caches\2.4\scripts\asLocalRepo15_dhjxrnvsgiyg1ow3dfj4myl7\InitScript\initscript\cache.properties (The system cannot find the file specified)

I try file/invalidate caches/restart.. and rebuild project but am still getting this error message. How do I fix it?

Wyetro
  • 8,439
  • 9
  • 46
  • 64
max
  • 5,963
  • 12
  • 49
  • 80
  • Check if disabling **Instant Run** in the *Preferences* of *Android Studio* makes a difference. In was the solution for the issue in my setup. – JJD Nov 30 '17 at 11:30

16 Answers16

151

You don't have to delete all .gradle folders and no need to reinstall Android Studio.

I have the latest version of Android Studio and I faced that problem, the only thing that worked for me is to:

  1. Navigate to C:\Users\user\.gradle\caches\2.x\

  2. Copy the folder scripts , scripts-remapped and paste it somewhere safe just in case anything went wrong you will place it back

  3. Delete this folder scripts and scripts-remapped from the directory C:\Users\user\.gradle\caches\2.x\

  4. Sync Project with Gradle Files and you are done.

enter image description here

When you sync your project Android Studio will generate new cache files.

You also need to delete buildOutputCleanup.lock from projectLocation/.gradle/buildOutputCleanup in case the above 4 steps do not work out.

It worked for me I hope it will work for you.

Community
  • 1
  • 1
Salam El-Banna
  • 3,784
  • 1
  • 22
  • 34
11

Reinstall Android Studio again is not an option!

To fix the problem:

cache.properties (The system cannot find the file specified)

go to :

 C:\Users\[User]\.gradle\caches\

Delete folders \2.4 and \2.8

introducir la descripción de la imagen aquí

Restart Android Studio!.

Community
  • 1
  • 1
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • 3
    If deleting `2.4` and `2.8` doesn't work for you, make sure you take note of the folder number in the error message. It might be something else other than `2.4` or `2.8`. Mine was `2.14.1` – Ojonugwa Jude Ochalifu Sep 08 '16 at 20:01
8

You don't have to reinstall Android Studio or no need to delete all .gradle folder.

I am reinstalled the latest version of Android Studio and still I faced that problem. It caused my to rename the "Android Projects" folder on my desktop in my case.

The only thing that you have to do:

1-Navigate to C:\Users\user_name.gradle\caches\2.4 or (2.8 if error in it otherwise)

2-Copy the folder "2.4" or "2.8" and paste it somewhere safe just in case anything went wrong you will place it back

3-Delete this error folder from the directory C:\Users\user.gradle\caches\2.4\ (or \2.8)

4-Close the Android studio & restart it.

During restart it sync your project & Android Studio will generate new cache files.

It worked for me I hope it will work for you... :)

Omkar
  • 3,040
  • 1
  • 22
  • 42
Taiful Tomal
  • 89
  • 1
  • 1
7

I have the same problem, I just delete .gradle from C:\Users\user\.gradle\caches\2.4\ and from my application too.

Of course close Android Studio and start Android Studio again.

Wyetro
  • 8,439
  • 9
  • 46
  • 64
destinydz
  • 171
  • 2
  • 3
  • Deleting the .gradle directory from the project folder was enough to solve the issue for me – Trent Feb 22 '17 at 01:40
  • This worked for me. The accepted answer, above, did not work for me... I had already deleted from the `user\.gradle` location. That was not enough. I had to delete from your suggested: `(project location)\.gradle`. – Dale Feb 25 '17 at 02:05
4

I found the solution to my question, but I do not know whether it is the optimal solution:

I deleted all .gradle folders in user library and reinstalled android and then it worked.

Wyetro
  • 8,439
  • 9
  • 46
  • 64
max
  • 5,963
  • 12
  • 49
  • 80
4

No need to reinstall anything.

Just delete the 2.4 and 2.8 folder located at C:\Users\user\.gradle\cachesdirectory and reopen android studio. It will generate new cash files so now the build should be successful.

Sabeeh
  • 1,123
  • 9
  • 11
3

Easy solution. Go ahead and create an empty cache.properties file under the path specified in the error log. The error should then disappear.

Wyetro
  • 8,439
  • 9
  • 46
  • 64
Manoj Shrestha
  • 4,246
  • 5
  • 47
  • 67
3

As said in the above examples i have tried resolving with extra steps:

  1. Navigate to the respective folder C:\Users\user.gradle\caches\2.14.1\
  2. Copy both the folders "scripts" and "scripts-remapped" into a safe place.
  3. Now, DELETE BOTH THE FOLDERS "scripts" and "scripts-remapped" in the location C:\Users\user.gradle\caches\2.14.1\
  4. Finally, try to sync the gradle.
  5. Android Studio will ask to Upgrade the Gradle plugin. So click on Upgrade the gradle.

(If not try to Restart the Android Studio IDE completely.)

Finally, it is done for me...!!!

2

Removing the {project-path}/.gradle/buildOutputCleanupcache.properties.lock

Work for me..

  • This solution worked for since I did not have the folder .cache. Somehow it got deleted and none of the solutions above worked. – Sibgha Jun 21 '23 at 12:04
1

Deleting the "scripts" folder and rebuilding the project will solve this problem.

Bö macht Blau
  • 12,820
  • 5
  • 40
  • 61
  • @Kaisar Hossein - I hope I've understood what you wanted to say. Please note that the Community prefers posts without expressions like "thanks", "hope this helps" etc. If I misunderstood you can always edit your own posts as often as you like :) – Bö macht Blau Apr 27 '16 at 08:35
1

I don't know why a great developer as Google can't manage this issue by them selves it is very easy to delete the cached folder and regenerate it programmatically. Any way just navigate to C:\Users\user.gradle\caches\ and open the latest version folder, then delete the scripts folder. Go to android studio and sync project.

itxdev
  • 41
  • 2
0

Go to the folder indicated in the error message. Delete the cache.properties.lock file.

Aharon Manne
  • 712
  • 3
  • 11
  • 34
0

I download gradle and changed path of gradle from C drive to D drive and fixed it

enter image description here

Rajesh N
  • 6,198
  • 2
  • 47
  • 58
0

I have faced the same problem and i am using Android studio 3.0.1,

Well, Don't Reinstall the Android studio there is no need of reinstalling the Whole software

Do the following step and hope this will solve your problem.....

step - 1. Go to C:\Users\*user_name_of_your_system*\.gradle\caches\2.x/

step - 2. Delete this folder scripts and scripts-remapped

step - 3. Than in your android studio, Go to Tools/Android/Sync Project with Gradle Files

Done :)

if still problem is not solved than -

step - 4. Delete both the Build folder and than repeat step- 3

enter image description here

Ravi Vaniya
  • 1,562
  • 1
  • 17
  • 28
0

The quickest and more accurate approach to this problem is to remove from your project's .gradle/<version>/buildOutputCleanup folder the file cache.properties.lock This will do the trick. After that, just rebuild or sync your project.

Laurent Doda
  • 101
  • 1
  • 6
-1

As mentioned above,I faced same problem: Try this

  1. Remove scripts and scripts-remmaped folders in C:\Users\user.gradle\caches\2.14.1\
  2. restart android studio

THIS WORKED FOR ME.

V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50
  • 1
    Welcome to StackOverflow. Your answer doesn't seem to add anything that previous answers haven't already mentioned. StackOverflow is not a forum and as such answers should only be added if they provide new information. For more on how this site works try taking [the tour.](http://stackoverflow.com/tour) – numaroth Nov 07 '16 at 21:36