'R cannot be resolved to a variable' - gen folder is empty

前端 未结 14 2389
故里飘歌
故里飘歌 2021-02-13 22:34

I\'ve got an error:

R cannot be resolved to a variable

in line:

setContentView(R.layout.main);

but I can\'t r

14条回答
  •  长情又很酷
    2021-02-13 23:00

    Nothing mentioned above worked for me. However, I fixed it myself.

    Solution:

    If you've any other files except activity_main.xml / main.xml inside app_name/res/layout remove it and try clean and build.

    Note:

    The unwanted files or (rather used later) files inside app_name/res/layout would be *.out.xml. Remove the same.

提交回复
热议问题