blog-"cannot resolve symbol R" in Android Studio

"cannot resolve symbol R" in Android Studio

"cannot resolve symbol R" in Android Studio

The "Cannot resolve symbol R" error in Android Studio occurs when the project cannot find the R.java file, which stores references to resources. Fix by rebuilding the project.

I had this issue too. A simple gradlew clean and gradlew build did the trick.

Click on Build->Clean Project and that will perform a gradle clean

You should do two things, first clean the project (in build menu) - it deletes the build directory which may be the culprit:

cannot_resolve_symbol_R_in_android_studio_1.png



Next, Sync project with Gradle files (under file):

cannot_resolve_symbol_R_in_android_studio_2.png


This is the placement for the items in Android Studio 3.6.1 on Windows 10.

If all else fails, Invalidate Caches and Restart (under file) usually does the trick. This closes down the whole program and takes the most amount of time, in my opinion.

cannot_resolve_symbol_R_in_android_studio_3.png

To clarify, I am running this on windows 10, but it should work on MacOS and Linux as well.