R 无法解析 - Android 错误 [英] R cannot be resolved - Android error

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

问题描述

我刚刚下载并安装了新的 Android SDK.我想创建一个简单的应用程序来测试它.

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

向导创建了以下代码:

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 给了我错误

R 无法解析

在线

setContentView(R.layout.main);

为什么?

PS:我在 res/layout/ 下确实有一个名为 main.xml 的 XML 文件.

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

推荐答案

AndroidManifest.xml 值得一看.属性 package 具有正确的值.

It is worth checking in AndroidManifest.xml. The attribute package has the correct value.

即:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="your.correct.package.name"
   ...

更改后,将重新生成 R.java.

After you change that, the R.java will be re-generated.

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

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