What works for me to solve this issue is to edit Android Manifest XML and the project properties.
In Android Manifest set the target version to the latest version:
In Project Properties set also the latest version:
# Project target.
This will work if the Android project has successfully run before but due to the latest version update of Android Studio software, the "Android R cannot be resolve to a variable" error is shown. Google wants you to set your project compatible to the newest Android version.
Cheers..Hope it helps.. :)