I would like to fix this error
R cannot be resolved to a variable
I looked up many answers, but I could not get the right one;
I had the same problem. I didn't have any lines stating "import something.R". Cleaning and rebuilding also didn't solve the issue.
It turned out to be because of the name of a layout xml file. Those files can only contain lowercase letters, or numbers, or underscores. When I changed the filename (and everything that refers to it) from myLayout.xml to my_layout.xml, everything worked.