Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Dev - R.layout.main , Variable 'R' cannot be resolved

Tags:

android

We are new to Android and we are trying to develop a new application. We installed all the basic setup of Android. We tried to run the Android Sample projects in Eclipse. But while to compile the following lines and a few other lines that uses the variable 'R' throws up an error.

setContentView(R.layout.activity_main);

'R cannot be resolved to a variable'. I do not understand what is causing the error. Anyone help me out in this issue.

like image 845
Manoj Kumar Avatar asked Dec 09 '22 04:12

Manoj Kumar


2 Answers

check that the import for R class is not

import com.android.R;

and you should make it

import yourpackagename.R;

then recompile

like image 107
confucius Avatar answered Dec 21 '22 10:12

confucius


Please try to clean the project, and try compiling again.

If not solved, refer to R cannot be resolved - Android error

like image 26
Jason Kuang Avatar answered Dec 21 '22 11:12

Jason Kuang