[英]First Android App (32/64 bit issue?)
I am trying to build the "hello world" example on Eclipse (tried NetBeans as well). 我正在尝试在Eclipse上构建“ hello world”示例(也尝试过NetBeans)。 The code is very simple:
代码很简单:
package com.example.myfirstapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
I get 2 "R cannot be resolved to a variable" errors. 我收到2个“ R无法解析为变量”错误。
As this seems to be a known issue, I already tried all the solutions regarding import, clean, restarting Eclipse, checking the manifest, etc 因为这似乎是一个已知问题,所以我已经尝试了有关导入,清理,重新启动Eclipse,检查清单等的所有解决方案。
A few of the answers, however, talk about some issue with missing 32-bit libraries on 64-bit systems (I use 64b Windows 7). 但是,有几个答案是关于64位系统(我使用64b Windows 7)缺少32位库的一些问题。 I also noticed that Eclipse does not flag errors in ANY other folders.
我还注意到Eclipse不会标记任何其他文件夹中的错误。 Also, that my project gen folder is empty.
另外,我的项目gen文件夹为空。
Since the code is very simple, I am pretty sure the problem is elsewhere. 由于代码非常简单,因此我可以肯定问题出在其他地方。 Unfortunately, I do not know enough about Java, Eclipse or Netbeans to fix it.
不幸的是,我对Java,Eclipse或Netbeans的了解不足以解决它。
I would appreciate any help. 我将不胜感激任何帮助。
You are missing the java import needed to resolve to the activity_main.xml, so add 您缺少解析为activity_main.xml所需的Java导入,因此添加
import com.example.myfirstapp.R;
(this should be whatever your app package is your androidmanifest and then ".R") (这应该是您的应用程序包是您的androidmanifest,然后是“ .R”)
under your package line ( package com.example.myfirstapp;
) 在您的包装行下(
package com.example.myfirstapp;
)
You IDE should stop complaining 您的IDE应该停止抱怨
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.