-1

I have started a new application project in android and I am getting this strange error on R file.I have done many projects but this is for the first time that an R error is coming as R file is generated automatically.There is no error in my xml or class files as I have just started the project.This is what its showing-:

    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
R cannot be resolved to a variable. 

I tried creating the R class but it shows up in src folder and not in gen folder.Please help me out here anyone.Thanks in advance.

3
  • in your project R.java file is not created due to any error in your any xml file. I'm correct?? Commented Apr 10, 2013 at 7:07
  • You made angry to android's HULK (R.java) :D Commented Apr 10, 2013 at 7:07
  • Thanks yugesh...that thought didn't cross my mind at all..silly me..thanks a lot Commented Apr 10, 2013 at 7:14

6 Answers 6

2

Delete R.java file from your source folder. Now Clean your project

and also try this.

Right Click on your Projectname >> Android Tools >> Fix project Property

Sign up to request clarification or add additional context in comments.

Comments

1

Check your Java compiler version, it should be 1.6.

Comments

1

Clean and build your project. This will generate R.java to you auto generated files folder.

Comments

1

Delete your R.java which is created under your src directory and then do clean and build.

Comments

1

Clean the project of course but if you any imported lib like xxx.R delete

Comments

1

Check the problems tab in eclipse IDE, it must be showing some errors.

otherwise clean and build.

Also check Build Automatically option in project menu.

1 Comment

Open problems tab like this if its not open = Window->Show View->Problems

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.