Android Studio重复文件 [英] Android Studio Duplicate Files

查看:79
本文介绍了Android Studio重复文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在源代码中得到重复的文件:

I am getting duplicate files in my source code:

这种情况在Android Studio中经常发生,并且会发生所有类型的文件,而不仅仅是gradle文件.通常在结帐新分支或Swith分支时发生.

This happens quite often with Android Studio and it happens will all types of files, not just gradle files. It typically happens when I checkout a new branch or swith branches.

是什么原因造成的,我该如何预防?

What is causing this and how can I prevent it?

请注意,此问题最初与图像文件一起发布,因此图像得到了答案.但是,这不仅限于图像文件,而且我了解为什么会有多个图像文件用于不同的屏幕密度.我进行了更新,以反映有其他文件正在重复.

As a note, this question was originally posted with image files, thus the image answers. However, this is not limited to image files and I understand why there are multiple image files for different screen densities. I have updated to reflect that there are other files being duplicated.

推荐答案

您是否有Mac,并且您的项目是否存储在文档"中?目录?

Do you have a Mac, and is your project stored in your "Documents" directory?

包含"的文件名当iCloud无法协调文件的两个版本时,将生成2" .例如.如果您有两台计算机,并且它们都共享其文档",通过iCloud目录,并在两台计算机上同时更改文件,iCloud最终会创建例如 build 2.gradle 文件.

Filenames that include " 2" are generated by iCloud when it can't reconcile two versions of a file. E.g. if you have two computers, and both of them share their "Documents" directories via iCloud, and a file were to be changed simultaneously on both computers, iCloud would wind up creating e.g. a build 2.gradle file.

我发现这是发生在我身上的,即使我只使用一台计算机来完成我的工作.我怀疑Android Studio可能直接与iCloud交互,而没有意识到它正在处理已经备份到iCloud的文件.(请参见 Android Studio生成数百个重复的"2"文件).

I found this was happening to me, even though I'm only using one computer to do my work. I suspect that Android Studio may be interacting with iCloud directly, not realizing that it's working on files that are already backed up on iCloud. (See Android Studio generating hundreds of duplicate " 2" files).

我似乎已通过将项目目录移出文档"来解决此问题.无论如何,从那以后我就再也没遇到过问题.

I seem to have fixed it by moving my project directory out of Documents. At any rate, I haven't had a problem since I did that.

(感谢Mike M.注意到我们问题之间的相似性.)

(Credit to Mike M. for noticing the similarity between our problems.)

这篇关于Android Studio重复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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