R cannot be resolved to a variable怎么解决

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mMsgRev = (TextView)findViewById(R.id.receive_msg);
    mMsgEdit = (EditText)findViewById(R.id.edit_msg);
    mMsgSendBtn = (Button)findViewById(R.id.send_msg);
            以上R都出现了R cannot be resolved to a variable的问题,可是R.java文件还可以自动生成,求大神指教

R是一个类型还是一个对象,如果是类型,那么id是静态成员么?
另外,R所在的命名空间导入了么?

Android开发过程中,碰到R cannot be resolved to a variable的报错信息,好像没有很确定的错误原因,一般来说,我总结出几个可能的解决方法,希望试过以后管用。。。

  1. 检查Android 的SDK是否丢失需要重新下载,检查build path 2.确保class没有import Android.R; 3,错误class引用的layout的xml文件没有......
    答案就在这里:R cannot be resolved to a variable 解决办法
    ----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

Android开发过程中,碰到R cannot be resolved to a variable的报错信息,好像没有很确定的错误原因,一般来说,我总结出几个可能的解决方法,希望试过以后管用。。。

  1. 检查Android 的SDK是否丢失需要重新下载,检查build path 2.确保class没有import Android.R; 3,错误class引用的layout的xml文件没有......
    答案就在这里:R cannot be resolved to a variable 解决办法
    ----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

出现这个问题一般是因为你的R.java文件没有引用正确或者这个文件不存在。因此这就出现两种情况。第一种,你的项目有可能为自动引用android.*R.java,对于这种情况只需要删除R.java的引用,重新进入R.java.
而第二种,又可能是你的项目本身出错,导致R.java没有生成,所以就不存在。解决方法是修改项目里面错误,clean工程后,Builde All工程

楼上正解,而且你可以去你R.java去看看,到底是什么问题