Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"cannot resolve symbol R" in Android Studio

In every instance in all of my classes where I reference R.id.something, the R is in red and it says "cannot resolve symbol R". Also every time there is R.layout.something it is underlined in red and says "cannot resolve method setContentView(?)". The project always builds fine. It is annoying to see this all the time. I have read many other questions on here about something similar but most involved importing projects from Eclipse. I am using what I believe to be the most recent version of Android Studio and the project was created with Android Studio and worked without any "cannot resolve R" problems. I would like to know what causes this if anyone knows.

like image 382
ez4nick Avatar asked Jun 11 '13 21:06

ez4nick


People also ask

Can not resolve r Android?

"R cannot be resolved" arise only if there is a problem with some of your resource files. So the best and effective way is delete the last done xml or drawable in res file. and then again start from there according to android coding norms. This is the only way.

What is Package R in Android Studio?

The R class is generated automatically from the application's resources. It contains the id s for these resources and is contained in the package named in the <manifest> tag in the corresponding AndroidManifest. xml file. If there are no errors in the resource XML files, the R.

What does Cannot resolve symbol mean?

In JavaLanguage, if you get 'cannot resolve symbol', you have used a name that the compiler hasn't recognized. Class names -- If it is a class name, the compiler cannot find the class.


1 Answers

I had this 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

like image 167
Vipassana Vijayarangan Avatar answered Oct 01 '22 22:10

Vipassana Vijayarangan