How To Fix “Cannot Resolve Symbol R” In Android Studio

Not only you, but every Android Developer has run into the same error “cannot resolve symbol r” in android studio.

This problem happens when you shift code to another system or while building the android project for the first time. So when you create a new activity or new class you will see an error message like “cannot resolve symbol r” with a red underline.

In android studio letter R stands for the resources and this error occurs because of the build process not able to sync resources with your project.

Below you can find the possible ways to fix cannot resolve symbol r in android studio.

  1. Update Project Gradle To Latest Version
  2. Sync Project With Gradle File
  3. Clean and Rebuild Project
  4. Invalidate Caches / Restart

Method 1: Update Project Gradle To Latest Version

Always use the latest version of gradle to work android studio properly. If you are using an older version of gradle then you defiantly facing this error. To update gradle to the latest version you can follow below step by step process.

  • First, open the android studio project that shows the error.
  • Expand the Gradle Scripts option at the left panel and open the build.gradle (Project: App Name) file.
  • Inside the dependencies, you need to update the gradle to the latest version as shown in below image.

cannot resolve symbol r

  • You can find the latest version of the gradle plugin here.
  • After that, you need to sync the project to apply changes to android studio.

Method 2: Sync Project With Gradle File

Once you update the gradle plugin from the above method you need to sync project with the gradle file. Follow these steps:

  • Open android studio and click on Files > Sync Project with Gradle Files option.

cannot resolve symbol r

  • You can also do the same by click on the Sync Project With Gradle Files icon as shown in below image.

cannot resolve symbol r

Method 3: Clean and Rebuild Project

If you are still facing the error then clean and rebuild the android studio project by following below steps.

  • Open android studio and click on Build > Clean Project option.

cannot resolve symbol r

  • After your project clean successfully click on Build > Rebuild Project option.

  • It will take 4-5 minutes to complete the process and error will be solved.

Method 4: Invalidate Caches / Restart

By invalidating caches cannot resolve symbol r error will disappear. To do this follow the below steps.

  • Open android studio and click on File > Invalidate Caches / Restart option.

cannot resolve symbol r

  • It will take 4-5 minutes to complete the process and error will be solved.

Final Words: I hope guys now you can easily solve cannot resolve symbol r in android studio. If you are still facing this error then let me know in the comments section below.

Leave a Reply

Your email address will not be published. Required fields are marked *