在 Android Studio 中构建项目时出错 [英] Error in building project in Android Studio

查看:55
本文介绍了在 Android Studio 中构建项目时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全新安装 Android Studio 并启动新的 android 项目.当试图运行它时.从 Gradle 得到这个错误

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 文件夹,但没有任何效果.

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

推荐答案

我遇到了同样的问题,仅删除 cache.properties.lock 是不够的.

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

解决方案,如前所述,是删除 cache.properties.lock 文件,但不仅仅是在 Android Studio 指向的文件夹中.我需要删除 .gradle\caches\VERSION 中的每个锁定文件.

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\caches\VERSION\ 并运行它.之后我的 Android Studio 不再抱怨了.

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

希望能帮到你!

这篇关于在 Android Studio 中构建项目时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆