Hi everyone.
I am a noob, just beginning to learn programming languages. So, read with caution.
I faced the same problem after running the project successfully many times. After all I discovered it was just a typo in one xml file. I put some number into a tag, without noticing. After remove it, the R problem disappeared.
As “nemo” said above, R is a static class that works using the xml code. If xml is wrong, R will not be correctly built.