A .gitignore for Android

In my previous post, I talked about how to set up a standalone Android build system, and in passing, mentioned pulling the source to be build from some repository. Of course, before you get to that point, you have to get the source into the repository, and if you are using Android Studio you also have a bunch of metadata files which you might or might not want to store. 

With Git, this is where the .gitignore file comes in (other source repositories are available).

The .gitignore file tells Git which files should be ignored for SCM purposes, such that if you make a change to say, the way the project is displayed in your particular instance of Android Studio, this is not stored in the SCM since it's not really important.

Android Studio helpfully ships with a standard .gitignore file, however, I found there were still some spurious files being pushed up to Github. After some research, I'm currently using the following:

# Private Build Information

# Built application files

# Files for the ART/Dalvik VM

# Java class files

# Generated files

# Gradle files

# Local configuration file (sdk path, etc)

# Proguard folder generated by Eclipse

# 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

Most of these are self explanatory from the comments - essentially we want to ignore any generated and transient artifacts, and any IDE files which are specific to our local install.

One part I will call out is the following:

# Private Build Information

These files are used by my build to provide overrides of certain build information. Since the source for the Controller for Mote project is public, I didn't want this potentially sensitive information being pushed to GitHub, hence the ignore. The cool part is that the build will work just fine without them, and that will be the subject of a future post,


Leave a Reply

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

Scroll to top