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

  1. Step 1: Open the File Menu, select Clean, then click on Apply to clean all files.

Method 2: Rebuild Project from Scratch

  1. Step 1: Delete the build.gradle file and any other files in the build directory.

Method 3: Update Gradle Distribution

  1. 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.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions