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). For example:
If I look at the build folder, I can see that
For example, if the offending folder is “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.
If I manually delete the “build” folder (either in Android Studio, or via File Explorer) the next build process completes without error. 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”. For each folder, the contents of the folder (R.java) are deleted, and then the folder is deleted. 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
答案 0 :(得分:0)
我知道了。我使用备份工具(Genie Timeline Home 2017)。该工具的工作原理是持续监视存储集中指定的文件,并定期(每6个小时)对最近的更改进行快照。
显然,在删除文件夹的内容然后删除文件夹时,监视存在某种间歇性的同步问题。从存储集中删除“ build”文件夹即可解决问题。
我已经使用Genie Timeline多年了,并且仅在最近几个月中一直遇到此问题。不确定发生了什么。
答案 1 :(得分:0)
我一次又一次面临着同样的问题。每次删除Build文件夹时,都可以成功构建应用程序,下一次显示相同的问题。所以我做了一些对我有用的事情
现在必须成功构建应用程序。如果没有,请执行步骤4