起因是公司电脑因停电突然关机了,再打开Android项目就出现了下面的编译错误提示
Multiple build operations failed.
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\985f3e88c3ad6807163a55993f55e5af\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\3b7b2037358637dcaf67d546177831a3\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\af403c23b0ee558583f1805d402ae3ee\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\bdf539cee158ceb50ca0cea562812128\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\9cd446a69da8e63cfe48362ccb1a5bf8\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\139b49fe5d63ccc9fe6a88394005174b\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\874d0132424e1fbf3c5fc24e0a2ed14d\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\024ddf7a4a8836aabc2ad98d569cabed\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\a93b801723459e51c954775404bfd99c\metadata.bin
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\eaa58c4fe94757247b958107a947a469\metadata.bin
...and 8 more failures.
Could not read workspace metadata from C:\Users\admin\.gradle\caches\transforms-4\985f3e88c3ad6807163a55993f55e5af\metadata.bin
C:\Users\admin\.gradle\caches\transforms-4\985f3e88c3ad6807163a55993f55e5af\metadata.bin (系统找不到指定的文件。)
看了下网上教程,需要将C:\Users\admin\.gradle\caches\
这个目录删除,然后重新rebuild项目
但是作者没提的是: 如果删除了目录,将影响其他所有项目(即打开项目gradle可能都会重新下载相关依赖)
但是我不想重新下载各种依赖,琢磨了下,可以设置单独某个Android项目的gradle的缓存目录来解决问题,则也可以不影响其他项目
可以在设置之前,将C:\Users\admin\.gradle
目录里面除了caches的其他文件夹都迁移一份过去(这样就不会重新下载太多东西)
评论区