-2

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.

CHP
  • 16,981
  • 4
  • 38
  • 57
user218554
  • 49
  • 1
  • 1
  • 5

6 Answers6

1

Check your Java compiler version, it should be 1.6.

Jachu
  • 405
  • 5
  • 10
1

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

InflexCZE
  • 722
  • 1
  • 14
  • 30
1

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

Kameswari
  • 738
  • 7
  • 27
1

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

Malcolmxappa
  • 103
  • 2
  • 12
1

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

Preet_Android
  • 2,332
  • 5
  • 25
  • 43
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.

Sunny
  • 1,441
  • 2
  • 13
  • 22