Typical .gitignore file for an Android app

JavaAndroidEclipseGitGitignore

Java Problem Overview


Just put an Android project under git (beanstalk) version control via the command line (mac terminal). Next step is to set up exclusions.

To those of you who have already been down this path:

What should a typical .gitignore file look like for an android project?

Project set up in Eclipse

Java Solutions


Solution 1 - Java

You can mix Android.gitignore:

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

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

with Eclipse.gitignore:

*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath

Solution 2 - Java

In addition to what the others have suggested, I'd like to add the proguard folder, in case you are using it. You can either ignore the whole folder or just dump.txt, seeds.txt and usage.txt. Basically, it's a good idea to keep mapping.txt versioned, so that you can debug obfuscated stack traces from your users. More details here.

Solution 3 - Java

This is my standard Android .gitignore and .hgignore file. It usually works pretty well.

bin
gen
target
.settings
.classpath
.project
*.keystore
*.swp
*.orig
*.log
*.properties
seed.txt
map.txt

It has eclipse, vim .swp files, mavens target folder and files for proguard mapping included.

Update: I have put my .gitignore for Android development online.

Solution 4 - Java

Well I know that the github/gitignore repository on GitHub has an android .gitignore file. This might be what you want as it should be very general for android development.

The actual content of the mentioned file:

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

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

Solution 5 - Java

Here is the one I use in my Android projects, it supports both ADT and Android Studio, so it is good if you are working with a team.

# General Folders

# gradle/ comment this when using gradle wrapper.
build/
bin/
gen/
tmp/
# proguard/ comment if not using proguard.
.gradle/
.settings/
.idea/

# General Files

.project
.classpath
.DS_Store
local.properties
*.iml
# gradlew comment when using gradle wrapper
# gradlew.bat comment when using gradle wrapper
Thumbs.db


# files specific to current project
your_apk.apk

Solution 6 - Java

Simply github can generate .gitignore for Android projects repositories

enter image description here

And its content will be like the following

# 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/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

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

# 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

Solution 7 - Java

In Addition, if you use IDEA's IntelliJ, and you build Artifacts (and you should), then you might want to add:

out/

(that's where Artifacts are built by default).

And if you don't want to share your IntelliJ project stuff ignore

.idea/

Solution 8 - Java

In my project root I have a file .gitignore. It contains:

/bin/
/gen/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionericView Question on Stackoverflow
Solution 1 - JavajamapagView Answer on Stackoverflow
Solution 2 - JavaFelixView Answer on Stackoverflow
Solution 3 - JavakeyboardsurferView Answer on Stackoverflow
Solution 4 - JavaKevin JalbertView Answer on Stackoverflow
Solution 5 - JavaMuhammad AlfaifiView Answer on Stackoverflow
Solution 6 - Javaahmednabil88View Answer on Stackoverflow
Solution 7 - JavaMartin MarconciniView Answer on Stackoverflow
Solution 8 - JavaCode PoetView Answer on Stackoverflow