Update Oct. 17, 2019:
———————
This is the official .gitignore file maintained by JetBrains:
https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
———————
List of directories and files to be excluded when importing into a version control (relative to the root of the project):
.gradle (directory)
build (directory)
local.properties (file)
app/build (directory)
.idea/libraries (directory)
.idea/gradle.xml (file)
.idea/workspace.xml (file)
There are a couple of different ways to have the above directories and files not present in the version control:
1. Exclude them from the initial import
2. Delete them after the import
svn delete -m "Delete .gradle dir" http://server/path/to/repository/.gradle
svn delete -m "Delete build dir" http://server/path/to/repository/build
svn delete -m "Delete app/build dir" http://server/path/to/repository/app/build
svn delete -m "Delete local.properties" http://server/path/to/repository/local.properties
svn delete -m "Delete .idea/libraries dir" http://server/path/to/repository/.idea/libraries
svn delete -m "Delete gradle.xml" http://server/path/to/repository/.idea/gradle.xml
svn delete -m "Delete workspace.xml" http://server/path/to/repository/.idea/workspace.xml
Now that we have gone through that, the version control does not have these directories and files, but locally, the project on your computer has these (if not they will be automatically generated when you first open the project in Android Studio or you build the project).
That means that we need to delete them from svn locally and tell svn locally to ignore them:
svn ps svn:ignore '.gradle local.properties build' .
svn ps svn:ignore build app
svn ps svn:ignore 'libraries gradle.xml workspace.xml' .idea
Update Oct. 23, 2018: Here is a .gitignore file that I use for all my Android Studio projects:
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
app/build/
# Here depending on your project you might need to include more build direcories
# Local configuration file (sdk path, etc)
local.properties
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
*.jks
*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# OSX_files
.DS_Store
Awesome blog , thanks for the help .
I frequently visit this post whenever I initiate a new Android project.
How do you do “1. Exclude them from the initial import”? Thank you
Thanks a lot man!