What files should be in my .gitignore
for an Android Studio project?
I've seen several examples that all include .iml
but IntelliJ docs say that .iml
must be included in your source control.
What files should be in my .gitignore
for an Android Studio project?
I've seen several examples that all include .iml
but IntelliJ docs say that .iml
must be included in your source control.
I support the committing of .idea folder (excluding
workspace.xml
andtasks.xml
). But I am starting to come to the conclusion that .iml files should be ignored.Here is the issue:
Open a project in a directory named "foo" for example and you will get foo.iml and that all seems well and good. The problem is that if I simply rename the directory to foo2 (or clone it into another directory name) when you try to open the project in Android Studio you will get three things:
I can find no way to prevent Android Studio from doing this iml file generation when the project is stored in a different directory. Adding them to source control is going to cause problems. Therefore I think perhaps we should ignore *.iml files and
.idea/modules.xml
Updated 7/2015:
Here is the definitive source from JetBrains
Directory based project format (.idea directory)
This format is used by all the recent IDE versions by default. Here is what you need to share:
.idea
directory in the project root except theworkspace.xml
andtasks.xml
files which store user specific settings.iml
module files that can be located in different module directories (applies to IntelliJ IDEA)Be careful about sharing the following:
dataSources.ids
,datasources.xml
can contain database passwords. IDEA 14 solves this problem.You may consider not to share the following:
.idea/libraries
in case they are generated from Gradle projectLegacy project format (
.ipr
/.iml
/.iws
files).ipr
file and all the.iml
module files, don't share the.iws
file as it stores user specific settingsWhile these instructions are for IntelliJ IDEA, they hold true 100% for Android Studio.
Here is a
.gitignore
snippet that incorporates all of the above rules:To circumvent the import of all files, where Android Studio ignores the "Ignored Files" list, but still leverage Android Studio VCS, I did the following: This will use the "Ignored Files" list from Android Studio (after import! not during) AND avoid having to use the cumbersome way Tortoise SVN sets the svn:ignore list.
Going forward, "Ignored Files" will be ignored and you can still manage VCS from Android Studio.
Cheers, -Joost
Github maintains useful gitignore items for various kinds of projects. Here is the list of useful gitignore items for android projects.
Android Gitignore in github
I had problems with ignoring build files, but this seems to work :-)
I disagree with all of these answers. The following configuration is working great for our organization's app.
I ignore:
/build
/.idea
(with possible exceptions, see comments in dalewking's answer)*.iml
local.properties
I think almost everyone agrees about
/build
.I got sick of constantly seeing messages about the various
library.xml
files that Gradle creates or deletes in/.idea
. Thebuild.gradle
will run on the developers's local when they first check out the project, so why do those XML files need to be versioned? Android Studio will also generate the rest of/.idea
when a developer creates a project usingCheck out from Version Control
, so why does anything in that folder need to be versioned?If the
*.iml
is versioned a new user will have to name the project exactly the same as it was when committed. Since this is also a generated file, why version it in the first place?The
local.properties
files points to an absolute path on the file system for the SDK, so it definitely shouldn't be versioned.Edit 1: Added
.gradle
to ignore the gradle caching stuff that should not be versioned (thanks Vasily Makarov).Edit 2: Added
.DS_Store
now that I am using Mac. This folder is Mac specific and should not be versioned.Additional note: You probably also want to add a directory to put your signing keys in when building a release version.
For copy/paste convenience: