189
votes

What files/folders can I safely ignore for inclusion with git?

I copied a good project, removed its gen and bin folders and tried to run the app. The Android Launch window says, "Your project contains error(s), please fix them before running your application. There is a red X on the icon to the left of the project in the Package Explorer. While the gen folder does not exist in Windows Explorer, it does in Package Explorer.

6
Do a 'refresh' of the project (right click on project / refresh) or via Menu > Project > Clean project.. - that might help you get rid of the error messages in Eclipse. Sometimes only a Eclipse restart helps as well, unfortunately. Eclipse isn't very reliable, but a good free tool for the beginning. (I've already switched to IntelliJ IDEA myself. Much better, not free though.)Mathias Conradt
@Mathias Lin: There's a new "community edition" of IntelliJ IDEA that is free.Greg Hewgill
@Greg Hewgill: yes, but the community edition doesn't have built-in Android support.Mathias Conradt
@MathiasLin intellij IDEA10: free IDE for Android development | JetBrains IntelliJ IDEA Blog I know that it's been a couple of years, but I stumbled on this article and noticed the outdated info, so I thought I would throw in the (now old) news. IntelliJ IDEA Community Edition does now offer support for Android Development. The announcement was published on October 19th 2010. Just a few months after your comment.DavidDraughn
@DavidDraughn Yes, using IDEA for 2 years already, can also recommend it.Mathias Conradt

6 Answers

261
votes

There are file types to ignore

# 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

# Eclipse project files
.classpath
.project

# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

From Gitignore on github

33
votes

What I usually add to .gitignore is:

bin
gen

bin and gen are constantly changed while coding, so there's no need to include them into the Git repository. Also, sometimes I add .classpath and .project which are Eclipse specific files, because maybe I want to create a new Android project based on these same sources, but in another OS or IDE.

With regards to the error, I would clean the project and/or try to run the Fix Project Properties utility (right-click on the Project -> Android Tools -> Fix Project Properties).

12
votes

Best solution today is probably to generate the exact .gitignore file you need. Just go to http://www.gitignore.io

The project is also on Github: https://github.com/joeblau/gitignore.io

7
votes

It's safe to ignore bin and gen, without problems. When I have problems with a project setup, I do this: First - have you looked at the 'Problems' tab in the view underneath the editor view - it generally gives more detailed information about project errors. If there's nothing conclusive there, I do the things below:

  1. Generally, when I'm having issues with Eclipse giving me phantom errors in the project, cleaning the project will fix it. It's in the menu, under Project>Clean.
  2. If that doesn't work, I'll usually try right clicking the project, going to Android Tools> Fix project properties.
  3. My last resort it to restart eclipse and delete the gen folder.
2
votes

the best way is use this site to generate: http://www.gitignore.io/

-28
votes

The simple answer to this question is *.* , basically it's completely safe to ignore anything you don't want to add to version control. That being said it really depends on what you're looking to accomplish by using Git. If you want to be able to checkout/import your project elsewhere from the same repository then you'll want to ignore at most /bin/. and /gen/., I wouldn't ignore the folders themselves (i.e. /bin, /gen) just for the sake of maintaining the proper directory structure for your project.

That answers the initial question, but is unrelated to the problem you are having. As far as solving the problem you are experiencing is concerned you would have to post more info, specifically what's listed in the Problems tab. If you can't see the Problems tab anywhere then click on the Window menu, then show view, then choose problems if it's there or click on other and look under General to find it.