Best Practices for adding .gitignore file to Android projects
These tutorials talk about which files in the Android project are committed and which files are ignored in a git repository.
It is important to know which files are gitignored on working with Android projects.
Android application gitignore file
Gitignore
is a text file that contains a list of files or patterns that are excluded while committing an Android project.
Following is a list of files and patterns for git ignore files.
java files are compiled into class files, so class files are not required to commit to the repository.
# Java class files
*.class
a lot of temporary files are generated.
# generated files
bin/
gen/
Gradle local files are not required, and the build folder contains the build output of a project
# Ignore Gradle files
.gradle/
build/
Configuration files like .iws
, .ipr
, .iml
, and local.properties can be excluded
# configuration
.iws
.ipr
.iml
local.properties
Build generated package files:
The following are compiler generate package files, excluded.
apk
is a compiled Android application generated during the compilation step .ap_
is a temporary file generated during the build step.
# built generated package files
*.apk
*.ap_
Dalvik VM files: Dalvik VM files are generated during the build process. these are local build temporary files, that can be excluded.
# the Dalvik VM files
*.dex
log files: these files are excluded for logs generated by db, SQLite
*.log
*.db
*.sqlite
For key store files:
Java key store files are for signing applications and can be ignored in Git
*.jks
IDE related files: Android projects are open in either Android Studio as well as Intelli IDEA.
These IDE-related settings files can be ignored.
# Android Studio / IntelliJ IDEA
*.iws
.idea/libraries
.idea/tasks.xml
.idea/vcs.xml
.idea/workspace.xml
/out/
Operation System-specific files These files contain OS-specific settings.
# OS temporary files
.DS_Store
.Spotlight-V100
.Trashes
thumbs.db
Thumbs.db
for local configuration files
# local configuration files
local.properties
For pro guard generated files & folders from Eclipse
# proguard foldr
proguard
for window shortcut link files
.lnk
Android app sample gitignore file example
Every Android application contains a gitignore
file.
Here is a sample example file.
# Crash log files
hs_err_pid*
# Java class files
*.class
# Ignore Gradle files
.gradle/
build/
# generated files
bin/
gen/
# configuration
.iws
.ipr
.iml
# local configuration files
local.properties
# built generated package files
*.apk
*.ap_
# Android Studio / IntelliJ IDEA
*.iws
.idea/libraries
.idea/tasks.xml
.idea/vcs.xml
.idea/workspace.xml
/out/
# OS temporary files
.DS_Store
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# For eclipse Eclipse
proguard/
# Android Patch ###
gen-external-apk
libs
# Packaging files
*.jar
*.war
*.ear
# Windows Installer files
*.cab
*.msi
*.msm
This is the initial gitignore files that you can use as a base. It includes files or folders specific to generate files by compilation, Editors, or OS-specific configurations.