Deep immersion in the .idea folder in Android Studio

Original author: Gahfy FR TH
  • Transfer

Deep immersion in the .idea folder in Android Studio


Like for many developers, the Android Studio’s .idea folder has always been like a black box for me: I knew that it existed, I knew that it was always added to .gitignore, but I decided to find out what those are for or other files and folders so that I have the ability to handle occasional git-conflicts, and to know exactly which file can be safely added to .gitignore, and which is not.


I have disassembled it on an example of the project on which I work. And I decided to share the result of what I found out, because found no documentation on this.


indicates the path to add to .gitignore


indicates the path that Android Studio has already added to .gitignore, and you should not version it.


indicates the path you should store in git.


assetWizardSettings.xml


This file stores the latest icon added using the Android Studio interface. It can be safely removed from the VCS.


Android Studio Wizard


caches


Caches, as the name implies, can be safely added to .gitignore.


I see no reason to keep it in VCS, but by default this folder is .gitignorenot added.


caches / build_file_checksums.ser


In fact, this file is a serialized instance of ProjectBuildFilesChecksums .


The file needs to check whether the change build.gradle, settings.gradle, local.properties, ~/.gradle/gradle.properties, gradle.propertiesor files build.gradleof your modules.


Android Studio uses this file to inform you that you need to sync gradle files.


codeStyles


This folder contains the settings for the project code styles. It is useful to version it if you changed the default code styles.


dictionaries


The folder contains an entry that you added to the dictionary to check the code. This dictionary is important if you have strict rules in your CI system.


gradle.xml


I recommend removing this file from git. It may contain a local path to your version of gradle, as well as a path to your module. For example, you can develop a module in a separate repository, so the path to the module can be specific to each user.


For all these reasons, I finally delete the file gradle.xmlfrom the VCS.


inspectionProfiles


This folder contains specific Lint-rules for your project. Therefore, just like the folder dictionaries, it should be stored in git.


libraries


It contains a file that indicates where the jar files of your libraries are stored. Since the download path may be specific to each user, you should not store this folder in the VCS.


misc.xml


The file contains information about the project: Java version, project type, etc.


This information relates to the project and does not depend on the user. Therefore, it should be stored in git.


modules.xml


This file contains the paths to the .imlfiles of your modules. Therefore, by analogy, gradle.xmlit cannot be stored in git.


navEditor.xml


The location of your items in the navigation editor is stored here . If this information is relevant to your project, then you should save this file in git. Otherwise, feel free to add it in .gitignoreto avoid conflicts in the future.


runConfigurations.xml


The file name may give you a hint that it stores configurations that you can add by clicking “Edit Configurations”. This file must be stored in VCS.


Change configuration


vcs.xml


This file contains information about the VCS that you use in your project. It is used so that you can use a graphical interface to perform version control operations. It should also be added to git.


workspace.xml


It contains information about your work space in Android Studio. For example, the last position of the cursor on the file you opened. So this is definitely user information that doesn't need to be stored in git.


Results


I would suggest you add just three lines to the .gitignoredefault file :


/.idea/assetWizardSettings.xml
/.idea/gradle.xml
/.idea/caches
# Uncomment next line if keeping position of elements in Navigation Editor is not relevant for you
# /.idea/navEditor.xml

As I said at the beginning of this article, I did not find any documentation about the contents of the folder .idea, so the article may be incomplete and / or not 100% accurate. If you know something else that is not in this article, then write about it in the comments.


Also popular now: