Error in building project in Android Studio

2019-01-20 07:00发布

Freshly Installed Android Studio and started new android project. When tried to run it. Got this error from Gradle

Error:Could not open initscript class cache for initialization script 'C:\Users\Dexter\AppData\Local\Temp\asLocalRepo10.gradle' (C:\Users\Dexter\.gradle\caches\2.2.1\scripts\asLocalRepo10_d10e66d3o7exs19wwq4uj2zhv\InitScript\initscript).
java.io.FileNotFoundException: C:\Users\Dexter\.gradle\caches\2.2.1\scripts\asLocalRepo10_d10e66d3o7exs19wwq4uj2zhv\InitScript\initscript\cache.properties (The system cannot find the file specified)

I have tried to rebuild the project and also tried to delete .gradle folder but nothing worked.

10条回答
孤傲高冷的网名
2楼-- · 2019-01-20 07:37

I'm having the same problem and deleting just the cache.properties.lock is not enough.

The solution, as pointed before, is deleting the cache.properties.lock file, but not only in the folder pointed by Android Studio. I needed to remove every lock file inside .gradle\caches\VERSION.

So, I created a small .bat file with this:

del /s cache.properties.lock

Add this file to .gradle\caches\VERSION\ and run it. My Android Studio stopped complaining afterwards.

Hope it helps!

查看更多
Anthone
3楼-- · 2019-01-20 07:37

I have same problem. just restart your Gradle and then clean your project. i hope this help

查看更多
叼着烟拽天下
4楼-- · 2019-01-20 07:38

I am also getting the same error.
So what I did is this that I cleared the Temp folder (If you don't know where it is then just hit Window+R and enter %temp% OR you can type %temp% in address bar too in File Explorer).
Now again run the project, it should run fine.
I don't know the permanent solution but what I am telling it works for me. If anyone do know the permanent fix then please share that.

查看更多
地球回转人心会变
5楼-- · 2019-01-20 07:38

I had similar issues. For me the solution was simply to delete all files inside the folder C:\Users\Dexter.gradle\caches\2.2.1\scripts\ Also i removed VCS configuration from android studio. No need to install new Android Studio to fix the issue.

查看更多
贼婆χ
6楼-- · 2019-01-20 07:38

For Me Issue get resolved by giving permission

  1. For window C:\Users Right click on Users >> Click on Security Tab >> Add Group and username there as for example SYSTEm, your comany mail id

  2. For Linux

provide 777 permission for .android and .gradle folder by using sudo chmod 777 -R .android/ sudo chmod 777 -R .gradle/

查看更多
贪生不怕死
7楼-- · 2019-01-20 07:41

File -> Invalidate Cache / Restart worked for me.

查看更多
登录 后发表回答