Android: “main cannot be resolved or is not a field”

Posted: June 11, 2011 in Android

So I’ve been messing with Android development for awhile now and one of the noob errors I stumbled on awhile back was the compile error…

“main cannot be resolved or is not a field”

What this usually is caused by is letting Eclipse resolve the compile problem of “main” not being found. It resolves this by importing android.R. This is obviously not what we want.

To fix this simply change the import to be …

import hello.World.R

or whatever your package is named. This will resolve the “main” problem. Hopefully this helps!


Another Solution

ust throwing this out there, but try retyping things manually. There’s a chance that your quotation marks are the “wrong” ones as there’s a similar unicode character which looks similar but is NOT a quotation mark.

If you copy/pasted the code snippits off a website, that might be your problem.

Another Solution

This usually (or always) does it for me: Project – Clean – “your project”

  1. Anonymous says:

    Thanks for this!

    I wasted hours with this sh…

  2. tacio says:

    É o nome do meu projeto para eu importa?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s