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.
相关文章