R能够解决不了 - Android的错误 [英] R cannot be resolved - Android error

查看:231
本文介绍了R能够解决不了 - Android的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载并安装了最新的Andr​​oid SDK。我想创建一个简单的应用程序来试驾吧。

I just downloaded and installed the new Android SDK. I wanted to create a simple application to test drive it.

创建了这个code向导:

The wizard created this code:

package eu.mauriziopz.gps;

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

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

的Eclipse 给我的错误

研究解决不了

在线

setContentView(R.layout.main);

为什么?

PS:我有一个命名的XML文件的main.xml RES /布局/

PS: I do have an XML file named main.xml under res/layout/.

推荐答案

随着在previous答案很好的建议,确保你的Andr​​oid的目标设定:

Along with the great suggestions in the previous answers, make sure your Android target is set:

  1. 在您的项目右键单击
  2. 选择属性
  3. 在左侧菜单中选择Android版
  4. 勾选旁边的相应项目一箱构建目标。
  5. 单击应用和确定

编辑:一年后我发现了另一个原因。我有一个形象的.jpg我绘制的文件夹具有相同的名称为.png图像。在我的code引用这一形象一定是混淆了程序,并给了R无法得到解决的错误。

A year later I found another cause. I had a .jpg image in my drawable folder with the same name as a .png image. Referencing this image in my code must have confused the program and it gave the "R cannot be resolved" error.

这篇关于R能够解决不了 - Android的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆