I’m just starting to develop with android, and a followed a tutorial on google to get everything set up. I’m using eclipse and I have both the android sdk and the eclipse plugin installed, but when I create a new Android Project, I get an error on this line from the start.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
It Says that the “R” in “R.layout.main” does not exist. Is there class that i need to create or import? I’m really confused because i have thoroughly searched and cannot find anyone else with this issue.
this is quite a common mistake .
make sure that at the top of your java file of the activity , the import is not of android.R.layout (or whatever) ,since it should import the R of your own app (which is inside the gen folder).
if you still have problems with that , try to delete the gen folder , make sure the layout file is ok (meaning it’s a correct android layout file, without any mistakes), make sure all of the resources (all images, sounds , xml files , all that are in /res) have only the legal characters in their files names (which means they are lowercase english ,optionally with “_” and digits, but no more) , clean the project , and then import the generated file .
you can also use CTRL+1 on the red underline of the R that it complains about , and choose the one of your project.