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

Android Studio- What files and directories to exclude when importing into Subversion (or Git)
Tagged on:                 

4 thoughts on “Android Studio- What files and directories to exclude when importing into Subversion (or Git)

  • October 24, 2016 at 4:38 am
    Permalink

    Awesome blog , thanks for the help .

  • March 19, 2017 at 2:19 pm
    Permalink

    I frequently visit this post whenever I initiate a new Android project.

  • July 27, 2017 at 2:27 pm
    Permalink

    How do you do “1. Exclude them from the initial import”? Thank you

  • July 11, 2018 at 6:23 am
    Permalink

    Thanks a lot man!

Leave a Reply

Your email address will not be published. Required fields are marked *

*