TheRookierLearner TheRookierLearner - 10 months ago 155
Android Question

Cannot find R.layout.activity_main

I was trying to work out with multiple layout using some online tutorials. The thing is my program was building and compiling correctly as long as there was only one XML file. When I added multiple XML files, I am getting errors saying 'activity_main cannot be resolved or is not a field' for the line


In fact, every item which I used previously in
is now reporting error. I don't know what went wrong. Can anyone suggest what needs to be done?

Edit 1: I tried cleaning and rebuilding the project but that didn't help. Plus, I am importing the correct
file as in

According to @RubberDuck's comment, I as soon as I deleted the files again, the file was being generated after building the project. However, when I create new XML files and add elements in it, build the project, gets deleted.

Answer Source

If your XML's contain errors your generated file might not build try erasing most of their content and making sure id's and file names are not duplicated and no capitals and spaces are used. If it works you can start adding stuff.