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 issue and main reason why R.java was not re-generated is errors in any of the files in the project. Once we fix those the R.java should get generated.