0

Ok, I know there are several questions like this, but I've been through all of them and nothing seems to work! I have been using eclipse for almost a year now. I installed new softwares from the Help menu, and since then nothing is working! I re-installed eclipse and now I'm getting this "R cannot be resolved to a variable", even when I create a brand new project. Here's the code:

package test.pro;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

I am getting an error in the setContentView and getMenuInflater lines. I looked in the 'gen' folder, there's nothing there! I also checked the Java Build Path, it's fine. The ADT is updated. Can someone help me out here!!? I really need it!

1 Answers1

0

Usually this error is because of some error in layout, strings, dimensions or any other xml file. Look for such xml error, resolve it and you should be good to go. Also do perform a clean of your project. This error is very common with me too.

  • _I'm getting this "R cannot be resolved to a variable", even when I create a **brand new project**._ So I don't think there is a problem with the xml files but more with the ADT update – Alexis C. Jun 15 '13 at 14:01
  • It is an empty project, all it has is the default basic code. And cleaning didn't work either. – Abishek Ramasubramanian Jun 15 '13 at 14:03
  • Did you install ADT from market place? If yes then install it using Install New Software feature and adding that URL for android ADT plugin (just google install ADT plugin). The Eclipse marketplace plugin is buggy. – Piyush-Ask Any Difference Jun 15 '13 at 14:05