Reputation: 1232
Which files in an Android project should be committed to a version control repository? Which files should not be committed?
Right now my .gitignore file consists of the following lines:
# Android generated files #
###########################
android.keystore
local.properties
bin/
gen/
libs/
obj/
# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
# Eclipse generated files #
###########################
.settings/org.eclipse.jdt.core.prefs
Am I missing anything?
Upvotes: 54
Views: 19522
Reputation: 6220
Using darcs, one adds the tracked files explicitly, rather than excluding them with an ignore file. After creating the new android project, I recorded my initial commit with all .java
, .xml
, .gradle
, .properties
, and .webp
files added, except for local.properties
.
This command did that:
( fd .*.java & fd .*.xml & fd .*.gradle & fd .*.properties & fd .*.webp; )
| cat
| rg -v ^local.properties
| xargs -I {} darcs add {}
Upvotes: 0
Reputation: 5811
GitHub maintains an official list of recommended .gitignore files at this public repository.
For Android you can find it here
Or just copy/paste :
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# 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/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
Upvotes: 42
Reputation: 3783
As of Android Studio 2.2.2 (and was probably added well before this version) when you create a new project, Google add a default .gitignore file to the project for you with the following contents:
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
A little different from the above answers, as it also ignores the .idea folders, which tend to have a lot of files in them.
Upvotes: 0
Reputation: 1897
don't add bin folder and gen folder. They are not part of your sources they are generated. In future remember that you add only files necessary to build and run your project, and binary and generated files are not.
Yet if you're not using any tool like ivy or maven you may want your lib folder to present. Often when you use a library project, you also need to commit it
Upvotes: 3
Reputation: 31038
The general rule of thumb is to not commit any file that can be re-generated, into the repository. Having said that, you may want to add your project.properties
file to .gitignore
as well (if it exists).
Upvotes: 7