[英]“Could not delete path” on various folders under “build/generated/source/r”
For the last few months, I have been getting a sporadic, moving, build-time error “Could not delete path” for a folder in the “build/generated/source/r” folder (the exact folder changes). 在过去的几个月中,我在“ build / generated / source / r”文件夹中遇到了一个偶发的,移动的,构建时错误“无法删除路径”(确切的文件夹更改)。 For example: 例如:
If I look at the build folder, I can see that 如果查看构建文件夹,我可以看到
For example, if the offending folder is “localbroadcastmanager”: 例如,如果有问题的文件夹是“ localbroadcastmanager”:
If I try to build again (Build, Make Project), it will successfully delete the offending folder, and several subsequent folders. 如果我尝试再次进行构建(“构建”,“创建项目”),它将成功删除有问题的文件夹以及随后的几个文件夹。 And then it will (often) encounter the problem for another folder “later” in the file tree. 然后(通常)文件树中的另一个文件夹“后来”会遇到问题。
If I keep trying to build, it will eventually succeed, sometimes after failing ~20 times. 如果我继续尝试构建,它最终会成功,有时会失败约20次。
If I manually delete the “build” folder (either in Android Studio, or via File Explorer) the next build process completes without error. 如果我手动删除了“ build”文件夹(无论是在Android Studio中还是通过文件资源管理器),则下一个生成过程将正确完成。 Unfortunately, that is a lot of overhead to incur for each build iteration. 不幸的是,每次构建迭代都会产生很多开销。
My theory is that the gradle build task is recursively deleting the structure under “source/r”. 我的理论是,gradle构建任务是递归删除“ source / r”下的结构。 For each folder, the contents of the folder (R.java) are deleted, and then the folder is deleted. 对于每个文件夹,将删除文件夹(R.java)的内容,然后删除该文件夹。 Sometimes the folder deletion is initiated before the file deletion has completed, resulting in a lock on the folder. 有时,文件夹删除是在文件删除完成之前启动的,从而导致文件夹锁定。
System details 系统详情
Things I've tried 我尝试过的事情
I figured it out. 我想到了。 I use a backup tool (Genie Timeline Home 2017). 我使用备份工具(Genie Timeline Home 2017)。 The tool works by continually monitoring the files specified in the save set, and periodically (~every 6 hours) making a snapshot of the recent changes. 该工具的工作方式是持续监视存储集中指定的文件,并定期(每6小时)对最近的更改进行快照。
Apparently there was some kind of intermittent synchronization issue with the monitoring, when deleting the contents of a folder, and then deleting the folder. 显然,在删除文件夹的内容然后删除文件夹时,监视存在某种间歇性的同步问题。 Removing the "build" folder from the save set solved the problem. 从存储集中删除“ build”文件夹可以解决此问题。
I've been using Genie Timeline for years, and have been having this problem only for the last few months. 我一直在使用Genie Timeline多年,并且仅在最近几个月中一直遇到此问题。 Not sure what changed. 不知道发生了什么变化。
I am facing same issue again and again. 我一次又一次面对同样的问题。 Each time I delete the Build folder I can build app successfully ones, next time same issue shown. 每次删除Build文件夹时,都可以成功构建应用程序,下一次显示相同的问题。 So i did following things which worked for me 所以我做了一些对我有用的事情
Now app must get successfully built. 现在,应用程序必须成功构建。 If not do step 4 如果没有,请执行步骤4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.