-1

I am developing an android application.

    setContentView(R.layout.main);

    weightSpinner = (Spinner) findViewById(R.id.spinner1);
    weightUnitSpinner = (Spinner) findViewById(R.id.spinner2);
    heightSpinner = (Spinner) findViewById(R.id.spinner3);

Here I am getting error in these line i.e R cannot be resolved to a variable can any solve this.

vinay kumar
  • 1,451
  • 13
  • 33
Anwesh
  • 91
  • 1
  • 1
  • 12

3 Answers3

2
  1. Make sure that none of your XML files have any errors in them
  2. Run Project -> Clean...
  3. Make sure your java file is in the same package given in the Manifest. If not, import the R file manually.
Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
1

R is a generated class. You can find R.java in /gen folder if it is generated.

If there is no R.java in /gen, your project may have some other errors that you first fix them.
First fix any other error and then clean build your project.If that doesn't help, delete /gen folder, and clean build again.

vipsy
  • 427
  • 3
  • 9
0

Check the packages you have imported. If you see Android.R then delete it and clean.