Tag: eclipse

First line disappears from Eclipse console output

I was just running a standard Java file straight from Eclipse when I noticed something strange. The first line of output was not showing at all.

My code ran an analysis, got back a result and printed a couple of attributes from the result. I was getting all but the first line of output (even though I knew there was nothing wrong with the System.out.println code).

When I ran it in the terminal, I found a few hundred (or thousand) lines of debug output from the analyser which I had forgotten to disable. For some reason, Eclipse was ignoring this and only printing the remaining output. This consumed the first line too, for some reason.

As soon as I disabled the debug output from the analysis code, the output was behaving normally again.

When Eclipse won’t generate/locate R.java

I’ve just come across a rather irritating habit of the ADT toolset for Eclipse and thought I’d share it.

If you get a red line under “R” in a reference to a layout, string or id, (e.g. the “R” in R.layout.main) then your problem could be one of the following:

  • You have ‘android.R’ as an import in your java class. This should not be there, remove it
  • You need to ‘clean’ your project by going to Project > Clean on the Eclipse menu bar
  • You do not have Eclipse set to ‘Build Automatically’. Do this by going to Project in the menu bar and ticking ‘Build Automatically’

My problem, however, was none of these. Eclipse just refused to generate R.java.

It turns out that if you have any errors in your xml files (strings.xml, layouts, etc.), then your R.java file will not be generated and you will not be told this is the reason.

Make sure any errors in your xml files are fixed and your R.java file should be generated automatically when you save.