java: R cannot be resolved to a variable

后端 未结 6 2072
北恋
北恋 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:16

    make sure there is no error in resource file, then as soon as you build your project you will get R.java generated, point to note here is no matter whether your java code does not compile, R.java will generate if there is no problem with resource file.

    If this step succeed you can import all necessary R.java file. Note that there may be multiple R.java file if you have included library project in your project. All R.java files will be in respective packages. for eg. I have "com.actionsherlock.R.java" & "com.myproject.R.java"

    in this case above case 1st import is must com.actionsherlock.R. However, I you no library project included, you need not import R.java as this file would be generate in the same package.

提交回复
热议问题