importing R. (android)

user2137032 picture user2137032 · Jun 3, 2013 · Viewed 33.8k times · Source

I have searched through Stack Overflow as I know this is a common question, but none of the solutions seemed to work for me. This included cleaning my project, deleting all imports and deleting the project and starting again entirely.

I am using the Eclipse specifically for android on mac (ADT bundle mac).

Whenever I create a new project I have errors immediatley in my src folder on the line setContentView(R.layout.activity_main);

and also on inflate.

Any suggestions other than those stated? It is literally before I have done any programming so cannot understand what is wrong.

EDIT: Fixed. Downloaded the SDK a second time and this seems to have fixed it.

Answer

stinepike picture stinepike · Jun 3, 2013

import The R class. The basic syntax is

import your_application_package_name.R;

If you have already imported it but it is not working then check if there in any error in your resource xmls. If so then r can be not generated and that error will be shown