Android Studio marks R in red with error message "cannot resolve symbol R", but build succeeds

Solution 1:

Just Click on Build -> Rebuild Project option in your Android Studio.

Solution 2:

I found that this issue was caused because I had errors in my XML files. Once you fix the XML errors, do a clean/build, it fixed the issue.

Solution 3:

Click on Build -> Rebuild Project and then click Tools -> Android -> Sync Project with Gradle Files.

Solution 4:

Make sure in your AndroidManifest.xml the package name is correct. That fixed the problem for me when my R.whatever was marked red!

I would also recommend checking all your gradle files to make sure those package names are correct. That shouldn't make everything red, but it will stop your gradle files from syncing properly.

Solution 5:

DO NOTHING. Just Update Android Studio. Resolve my problem! Work perfectly.