I was working on Android Studio for adding a short toast message.(I was making an Android Wear Application)
I couldn\'t know why this code has error on \'symbol R\'
Just in case any of the above answers don't work, the following solved the issue in my case...
Here's what I tried:
Multiple "cleans", "rebuilds" and "invalidate caches restart"
Attempts to manually add [my package].R,
This didn't work, so I uninstalled Android Studio, and reinstalled the latest version.
The accepted answer to the above link has the following steps (which I reproduce here):
Remove Android Studio files
Go to your user folder (%USERPROFILE%), and delete .android, .AndroidStudio and any analogous directories with versions on the end, i.e. .AndroidStudio1.2, as well as .gradle and .m2 if they exist. Then go to %APPDATA% and delete the JetBrains directory. Finally, go to C:\Program Files and delete the Android directory.
Remove the SDK
To delete any remains of the SDK, go to %LOCALAPPDATA% and delete the Android directory.
Delete Android Studio Projects
Android Studio creates projects in a folder %USERPROFILE%\AndroidStudioProjects, which you may want to delete.
I skipped 4), then uninstalled a separate Java 7 installation I had, for good measure.
Next I downloaded the latest Android Studio (3.3.2) and installed it.
A bit drastic perhaps, but now everything is working and the "Cannot resolve symbol R" error is gone.