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 use this .gitignore. I found it at: http://th4t.net/android-studio-gitignore.html
My advise would be also to not ignore the .idea folder.
I've imported a Git-based Eclipse project to Android Studio and that went fine. Later, I wanted to import this project with Git (like the first time) to another machine with Android Studio, but that didn't worked. Android Studio did load all the files but wasn't able to "see" the project as a project. I only could open Git-files.
While importing the project for the first time (from Eclipse to Android Studio) my old .gitignore was overwritten and the new one looked like this:
So, I tried to use an empty gitignore and now it worked. The other Android Studio could load the files and the Project. I guess some files are not important
(profiles_settings.xml)
for Git and importing but I am just happy it worked.https://github.com/github/gitignore is awesome collection
Android.gitignore
I'm kosher with adding the .iml files and Intellij sez to add the .idea folder but ignore .idea/workspace.xml and .idea/tasks.xml, but what about .idea/libraries/ ?
I don't see how it makes sense to add this. It has a list of XML files that list libraries the Android Studio project is supposed to know about. These are supposed to come instead from build.gradle defined dependencies -- not an IDE project file.
Also the contents of one of these files looks like this:
It doesn't make sense to commit this. What if the user specified a different home dir for gradle, or if they use a different gradle version, the path under
.gradle/caches/artifacts-xxx
is going to be different for them (i.e.artifacts-
the number appended on the end will relate to the gradle version release you are using.) These paths are not universal, and yet the advice is to check all this in?Using the api provided by gitignore.io, you can get is automatically generated. Here is the direct-link also gitignore.io/api/androidstudio
There is NO NEED to add to the source control any of the following:
So you can configure hgignore or gitignore accordingly.
The first time a developer clones the source control can go:
That's all
PS: Android Studio will then, through maven, get the gradle plugin assuming that your build.gradle looks similar to this:
Android studio will generate the content of .idea folder (including the workspace.xml, which shouldn't be in source control because it is generated) and the .gradle folder.
This approach is Eclipse-friendly in the way that the source control does not really know anything about Android Studio. Android Studio just needs the build.gradle to import a project and generate the rest.