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
build.properties
version.properties

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/workspace.xml
.idea/libraries
.idea/tasks.xml
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/vcs.xml

# Keystore files
*.jks

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

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
build.properties
version.properties

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