R.java 故障
我创建了一个新的 xml 文件,但有一个错误的 ?它阻止了 R.java 的重新生成。我尝试清理项目并修复项目属性,但没有成功。
然后我意识到 XML 正在通过重新创建自身来创建 R.java,因此我删除了 XML 文件,R.java 又回来了。
但现在,我在对 R.. 的所有调用上都收到错误,指出:
- 无法解析或不是字段
因此,例如我有
setContentView(R.layout.detectlayout);
错误:Detectlayout 无法解析或不是 字段
我所有对“R.”的调用的 。有什么想法吗?
我已经尝试了所有关于SO的建议,但没有运气=/
I created a new xml file, and had an errant ? in it that prevented R.java from regenerating. I tried Cleaning the Project, and Fixing the Project Properties but no luck.
Then I realized the XML was creating the R.java from recreating itself, so I deleted the XML file and the R.java was back.
Now though, I am getting an error on all the calls to R.. calls saying that :
- cannot be resolved or is not a field
So, for instance I have
setContentView(R.layout.detectlayout);
ERROR: detectlayout cannot be resolved or is not a field
for all of my calls to 'R.'. Any ideas?
I have tried all of the suggestions on SO already to no luck =/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看代码的“导入”部分。由于您删除了原来的 R,Eclipse 很可能会帮助您将 R 填写为 com.android.R 而不是 com.yourproject.R
我有时也会在 Eclipse 资源内容中遇到问题,有时我发现关闭并打开“自动” buiild”功能可能会有所帮助,或者简单地重新启动 Eclipse 有时可能会有所帮助。 Mac OS 下有点 bug。
Look at the 'import' section of your code. Since you deleted your original R, chances is Eclipse help you to fill in the R as com.android.R instead of com.yourproject.R
I also sometimes have problem in Eclipse Resource stuff, sometimes I found turning off and on the "auto buiild" function may help, or simply restarting Eclipse may sometimes help. It's kind of buggy under Mac OS.
如果导入 .R,就会发生这种情况。当你使用 R.java 遇到困难时,Eclipse 有时会自动添加它
This can happen if .R is imported. Eclipse will automatically add it sometimes when you have difficulty with with R.java
首先,不要费心删除 R 文件,它不会让事情变得更好,只会最糟糕,哈哈,
正如你所说,有时需要清理项目
当您开始修改资源时,最好选择项目的根目录并执行 alt+shift+o 来重新加载所有资源
然后按 f5 刷新树
然后清理项目,
您还必须检查 Eclipse 是否设置为自动构建(项目->自动构建)。
first don't bother deleting the R file it not going to make things better only worst lol
as you said you some times need to clean the project
when you start modifying resources its good to select the root of your project and do a alt+shift+o to reload all ressources
then f5 to refresh the tree
then clean the project
you also have to check that eclipse is set to build automatically (Project->build automatically).