当前位置: 代码迷 >> Android >> R cannot be resolved to a variable解决方法
  详细解决方案

R cannot be resolved to a variable解决方法

热度:75   发布时间:2016-04-28 04:06:15.0
R cannot be resolved to a variable
我新建了一个android项目以后,发现gen目录是空的。不知道为什么,请高手指点。
------解决思路----------------------
几两天这边一个新来的同事发遇到了
1.clean完编译下看有没有
2.还有可能ADT插件没有安装全(build tools)
3.可能代码有错
------解决思路----------------------
引用:
1、我clean过好几次了,依然不能编译。因为gen目录为空的。
3、代码不会有错的,因为我是新建了一个空的项目,默认的代码:
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);//R cannot be resolved to a variable
    }


    @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);//R cannot be resolved to a variable         
        return true;
    }
    
}
那看来只有可能是2、ADT插件没有安装全。那请问,怎么样才知道有没有把ADT插件安装全呢?

错了,好像不是ADT
你打开sdk manager,看下那个build tools有没有装
  相关解决方案