错误Android Studio中的建筑项目错误、项目、建筑、Studio

2023-09-09 21:08:01 作者:誓言终究敌不过的岁月

全新安装的 Android的工作室并开始新的Andr​​oid项目。当试图运行它。从摇篮得到这个错误

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)

我试图重建项目,并试图删除 .gradle 文件夹,但毫无效果。

推荐答案

我有同样的问题,仅删除cache.properties.lock是不够的。

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

解决方案,如前指出的,是删除cache.properties.lock文件,但不是唯一的由Android工作室所指向的文件夹中。我需要删除.gradle \\缓存内的每个锁定文件\\版本。

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.

所以,我创建了一个小的.bat文件与此:

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

del /s cache.properties.lock

添加此文件.gradle \\缓存\\ VERSION \\并运行它。我的Andr​​oid工作室之后停止抱怨。

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

希望它帮助!