java: R cannot be resolved to a variable

后端 未结 6 2011
北恋
北恋 2021-01-27 06:03

I know this question has been asked before but I am at my witts end with this. I have just created a new project and getting this error.

Ofcourse the R.java file is not

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-27 06:17

    If you have any errors in your resource files, the tools will not generate an R.java file. Look for and fix all errors in the .xml files before worrying about class com.example.myfirstapp.R not being defined. If you have no errors in the .xml files, then clean and rebuild your project.

    Also, just to rule out a programming environment problem if you're using Eclipse, right-click on the project name in the Package Explorer, navigate to Android Tools and select "Fix Project Properties".

提交回复
热议问题