简体   繁体   English

“构建/生成/源/ r”下各个文件夹上的“无法删除路径”

[英]“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 如果查看构建文件夹,我可以看到

  • Offending folder is present 存在违规文件夹
  • Offending folder is the first folder under the "r" folder 有问题的文件夹是“ r”文件夹下的第一个文件夹
  • Offending folder is empty 违规文件夹为空
  • Subsequent folders are present, and each contains 1 file: the R.file 存在后续文件夹,每个文件夹包含1个文件:R.file

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 系统详情

  • Windows 10 Windows 10
  • Android Studio 3.1.4 Android Studio 3.1.4
  • Anti-virus: Trend Micro Internet Security 12.0 防病毒:趋势科技网络安全专家12.0

Things I've tried 我尝试过的事情

  • Android Studio Android Studio
    • Build, Clean Project 建立,清理项目
    • Invalidate Caches/Restart 无效的缓存/重启
    • Delete "build" folder (works, but is not a tenable solution) 删除“ build”文件夹(可行,但不是可行的解决方案)
  • Anti-virus (Trend Micro) 防病毒(趋势科技)
    • Added "build" folder to "Exception List" 在“例外列表”中添加了“构建”文件夹
    • Disabled anti-virus 禁用的防病毒
  • Used Resource Monitor and Process Explorer to see if other process has lock on folder 使用资源监视器和进程资源管理器查看其他进程是否已锁定文件夹
  • Tried suggestions posted here: StackOverflow post: Could not delete path 尝试过的建议发布在这里: StackOverflow发布:无法删除路径

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 所以我做了一些对我有用的事情

  1. Delete "build" folder from your app directory 从您的应用目录中删除“ build”文件夹
  2. Got to Build -> Make Project (ctrl+F9) 进入Build-> Make Project(ctrl + F9)
  3. Build->Clean & Build->Rebuild project creates new Build Folder Build-> Clean&Build-> Rebuild项目创建新的Build文件夹

Now app must get successfully built. 现在,应用程序必须成功构建。 If not do step 4 如果没有,请执行步骤4

  1. File -> Invalidate Cashes and Restart. 文件->使现金无效并重新启动。 This will solve your problem 这将解决您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM