1

I'm completely new to Android programming and there's this thing bugging me already. I get the R cannot be resolved error in a freshly created project! Because it's freshly created, I didn't edit it at all, so I'm sure it has no errors and it should just be a hello world program. I checked and there's no

import android.R;

there and I have no idea what else could be causing this. Because of this error I can't even attempt practice in making layouts...

3
  • Try to clean your project. Try this hello world Commented Jun 26, 2012 at 10:14
  • Remove import android.R and import R with your project package name , you will get suggestions , just check it Commented Jun 26, 2012 at 10:26
  • Also check whether you got any errors in resources files like drawables,values etc Commented Jun 26, 2012 at 10:28

3 Answers 3

1

Try changing the project's API level, apply the changes and then revert to the old API level, then clean your project. I'm not sure how, but this worked for me sometimes.

Sign up to request clarification or add additional context in comments.

Comments

1

To clean android project....

Window -> Preferences -> General -> Keys (**Ctrl+Shift+L**)

in type filter text write build clean.

here you can bind the key. for ex Ctrl+Shift+L

1 Comment

Tried cleaning and that didn't help. I'm sure there's no error in my xml as I literally didn't change anything in there. It's just the initial setting.
0

Another solution. I changed the target sdk to 2.1 after creating the project. Android showed no errors in the layout, so I restarted eclipse (cleaning didn't help) and then Android marked the layout with a red x. It didn't recognize the match_parent parameter since it was introduced in Android 2.2. The solution is to change the target sdk to 2.2 or use fill_parent or wrap_content instead of match_parent.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.