简体   繁体   English

Android 问题:项目 r.java 在我清理/重建时消失

[英]Android Issue: Project r.java disappears when I clean/rebuild

Hi I'm having an issue with the r.java file.嗨,我遇到了 r.java 文件的问题。 It sometimes doesn't reference my xml files such as styles/strings etc (No errors).它有时不引用我的 xml 文件,例如样式/字符串等(无错误)。 However I heard project clean/rebuild helps, I did it and it has deleted my r.java file.但是我听说项目清理/重建有帮助,我做到了,它删除了我的 r.java 文件。 I've tried refreshing but to no avail.我试过提神,但无济于事。 Is there a way of getting it back?有没有办法找回来? I've been working on it all day and I can't get my head around it.我整天都在研究它,我无法理解它。 I've started new projects and this always happens.我已经开始了新项目,而且这种情况总是会发生。

Please help.请帮忙。 Thanks.谢谢。

The R.java file is built from your res xml files. R.java 文件是根据您的 res xml 文件构建的。 Cleaning will cause it to be deleted and you'll have to wait for a build to get it back.清理将导致它被删除,您必须等待构建将其取回。

Ways to force a build in Eclipse include强制构建 Eclipse 的方法包括

  • opening any file, making any change, including adding a space then removing it, then saving the file打开任何文件,进行任何更改,包括添加空格然后删除它,然后保存文件
  • Trying to run the app on emulator/device (though eclipse sometimes recognises the lack of R.java as an error and stops the procedure)尝试在模拟器/设备上运行应用程序(尽管 eclipse 有时会将缺少 R.java 识别为错误并停止该过程)
  • uncheck and re-check Project Build Automatically to force a rebuild取消选中并重新选中 Project Build Automatically 以强制重建

There are other ways I'm sure but these are the easiest.我敢肯定还有其他方法,但这些是最简单的。

Building the project should do the trick...构建项目应该可以解决问题...

(maybe you need to change something in the code before (just add a space)) (也许你之前需要在代码中更改一些东西(只需添加一个空格))

Make sure there are no errors in your xml files.确保 xml 文件中没有错误。 If this doesn't work try cleaning the project.如果这不起作用,请尝试清理项目。

Do you have 'Build Automatically' checked under Project in Eclipse.您是否在 Eclipse 的项目下选中了“自动构建”。 When you do a clean R.java and any other file in the gen folder are supposed to be deleted and recreated when you build.当您执行干净的 R.java 时,应该在构建时删除并重新创建 gen 文件夹中的任何其他文件。 If that still doesn't work then try removing the project from your workspace and re-add it.如果这仍然不起作用,请尝试从您的工作区中删除该项目并重新添加它。 That often times fixes a lot of issues with projects in Eclipse for me.这通常会为我解决 Eclipse 中的项目的许多问题。

It happened with my project too, just click on the project and ctl+z and you will get it back我的项目也发生了这种情况,只需单击项目并 ctl+z 即可将其取回

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM