问题:
I just downloaded and installed the new Android SDK. 我刚刚下载并安装了新的Android SDK。 I wanted to create a simple application to test drive it. 我想创建一个简单的应用程序来测试驱动器。
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);
}
}
but Eclipse gives me the error 但是Eclipse给了我错误
R cannot be resolved R无法解析
on line 在线
setContentView(R.layout.main);
Why? 为什么?
PS: I do have an XML file named main.xml
under res/layout/
. PS:我确实在res/layout/
下有一个名为main.xml
的XML文件。
解决方案:
参考一: https://stackoom.com/question/3iEL/R无法解析-Android错误
参考二: https://oldbug.net/q/3iEL/R-cannot-be-resolved-Android-error