Coding⏱️ 2 min read📅 2026-06-03
How to Fix: Android Studio marks R in red with error message "cannot resolve symbol R", but build succeeds
Fix Android Studio R class resolution issue.
Quick Answer: Clean and rebuild the project, and check the build.gradle file for any errors or missing configurations.
The error 'cannot resolve symbol R' in Android Studio is often caused by the build script not properly scanning for resources. This can happen when the project settings are not correctly configured.
🔧 Proven Troubleshooting Steps
Method 1: Clean and Rebuild Project
- Step 1: Open the File Menu, select Clean, then click on Apply to clean all files.
Method 2: Rebuild Project from Scratch
- Step 1: Delete the
build.gradlefile and any other files in thebuilddirectory.
Method 3: Update Gradle Distribution
- Step 1: Open the Terminal and run
gradlew --refresh-dependencies.
By following these steps, you should be able to resolve the 'cannot resolve symbol R' error in Android Studio.
❓ Frequently Asked Questions
Step 1: Open the File Menu, select Clean, then click on Apply to clean all files.
Step 1: Delete the build.gradle file and any other files in the build directory.
Step 1: Open the Terminal and run gradlew --refresh-dependencies.
🛠️ Related Fixes
How to Fix: Stuck in tutorial hell after 4 years: How do I b
Fix Stuck in tutorial hell after 4 years: How do I bui. Practice build
How to Fix: Trying to sync mutliple audio tracks to a movie
Fix Trying to sync mutliple audio tracks to a movie bu. Consider using
How to Fix: Failed to merge latest branches from upstream re
Fix Failed to merge latest branches from upstream repo. Try running 'g