Update Oct. 17, 2019:
This is the official .gitignore file maintained by JetBrains:



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

# Files for the ART/Dalvik VM

# Java class files

# Generated files

# Gradle files
# Here depending on your project you might need to include more build direcories

# Local configuration file (sdk path, etc)

# Log Files

# Android Studio Navigation editor temp files

# Android Studio captures folder

# IntelliJ

# Keystore files

# External native build folder generated in Android Studio 2.2 and later

# OSX_files

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

    Awesome blog , thanks for the help .

  • March 19, 2017 at 2:19 pm

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

  • July 27, 2017 at 2:27 pm

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

  • July 11, 2018 at 6:23 am

    Thanks a lot man!

Leave a Reply

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