What should be in my .gitignore for an Android Studio project?
Building on my normal Android .gitignore, and after reading through documentation on the Intellij IDEA website and reading posts on StackOverflow, I have constructed the following file:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# built native files (uncomment if you build your own)
# *.o
# *.so
# generated files
bin/
gen/
# Ignore gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Eclipse Metadata
.metadata/
# Mac OS X clutter
*.DS_Store
# Windows clutter
Thumbs.db
# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
.idea/workspace.xml
.idea/tasks.xml
.idea/datasources.xml
.idea/dataSources.ids
Also note that as pointed out, the built native files section is primarily useful when you are building your own native code with the Android NDK. If, on the other hand, you are using a third party library that includes these files, you may wish to remove these lines (*.o and *.so) from your .gitignore.
Updated to Android Studio 3.0 Please share missing items in comments.
A late answer but this alternative answer was not right for us ...
So, here's our gitignore file:
#built application files
*.apk
*.ap_
*.aab
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Windows thumbnail db
Thumbs.db
# OSX files
.DS_Store
# Android Studio
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
.navigation
captures/
output.json
#NDK
obj/
.externalNativeBuild
Since Android Studio 2.2 and up to 3.0, new projects are created with this gitignore file:
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
Deprecated - for older project format, add this section to your gitignore file:
/*/out
/*/*/build
/*/*/production
*.iws
*.ipr
*~
*.swp
This file should be located in the project's root folder and not inside the project's module folder.
Edit Notes:
Since version 0.3+ it seems you can commit and push *.iml and build.gradle files. If your project is based on Gradle: in the new open/import dialog, you should check the
"use auto import"
checkbox and mark the"use default gradle wrapper (recommended)"
radio button. All paths are now relative as @George suggested.Updated answer according to @128KB attached source and @Skela suggestions