• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Eclipse Noob getting roadblocked by errors

tgpoletti

Newbie
I am trying to learn how to program Java for Android on Eclipse. Right now, I know next to nothing about programming, and have been just looking through internet tutorials (eventually I am going to start purchasing books).

My problem mainly (I think) is that I do not really know how to use Eclipse. I'm writing very simple code that matches the code in the tutorials, but I get errors that I just cannot get rid of.

Here is one example:

setContentView(R.layout.main);
Button greenButton = (Button)findViewByID(R.id.green_button);

There is an error in both of these lines, with the references to main and green_button. In the tutorial, these words come up in blue text and are even auto-finished by my program does not seem to recognize them. green_button was an id created in main.xml and main is supposed to reference main.xml.

I've also gotten errors saying that my tags aren't close properly even if I know they are. Sometimes they go away when I retype them and sometimes they go away when I run the clean feature, but sometimes they don't at all.

I am sure I am going to running into this sort of thing a lot starting out, but I was wondering if there is some fundamental part of the software that I should know about that will take care of a lot of this stuff.
 
Eclipse can just be buggy sometimes parsing the xml. Always be sure there is no spaces or lines before your initial <xml> tag. Sometimes you can ignore the warnings, and as you've discovered the "project clean" command helps a lot.

If you are running eclipse on a slow computer it can sometimes take awhile to build the project. It builds and generates files on just about every change you make, and sometimes the errors you see just have to do with the fact that it is in the middle of building. You can disable this and it would run faster but I don't really recommend it unless you really have to. Having eclipse build lets you catch the real errors, even if it is slow.

Otherwise it's hard to say enless you can post the specific error. As a last resort you could try delete/uninstall everything eclipse/android and reinstall fresh.

You can also try deleting the folder: C:\Users\(your username)\.android

That's on Win7, not sure what platform you're on. hth
 
Eclipse can be a bit of a dark art, but with the exact error messages I can normally figure out what it's doing. Can you paste the exact error messages? I'll give you a hand then.
 
Back
Top Bottom