问题:
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: 向导创建了以下代码:
1package eu.mauriziopz.gps; 2 3import android.app.Activity; 4import android.os.Bundle; 5 6public class ggps extends Activity { 7 /** Called when the activity is first created. */ 8 @Override 9 public void onCreate(Bundle savedInstanceState) { 10 super.onCreate(savedInstanceState); 11 setContentView(R.layout.main); 12 } 13}
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