简体   繁体   English

有没有办法在Android Studio中生成R.java文件?

[英]Is there a way to generate the R.java file in Android Studio?

I have a saved Android project from long time ago and now I must to work on it. 我很久以前就有一个已保存的Android项目,现在我必须继续努力。

I've created a New Project in Android Studio and I've imported all the Java and XML files inside it but the R.java file is missing. 我在Android Studio中创建了一个新项目,我已经导入了其中的所有Java和XML文件,但缺少R.java文件。

I guess that it didn't save the original. 我猜它没有保存原件。 Can I recover it somehow or generate it? 我可以以某种方式恢复或生成它吗?

R.java is quite different in Android Studio than it is in Eclipse. R.java在Android Studio中与在Eclipse中完全不同。 Since you say this is an old project, I'm assuming that it was originally from Eclipse. 既然你说这是一个旧项目,我假设它最初来自Eclipse。 In Eclipse, R.java is included in the source tree. 在Eclipse中, R.java包含在源树中。 However, in Android Studio, it is hidden away. 但是,在Android Studio中,它被隐藏起来。 From another Stack Overflow answer : 另一个Stack Overflow回答

1. build 建设

This has all the complete output of the make process ie classes.dex, compiled classes and resources, etc. 这包含make进程的所有完整输出,即classes.dex,编译类和资源等。

In the Android Studio GUI, only a few folders are shown. 在Android Studio GUI中,仅显示几个文件夹。 The important part is that your R.java is found here under build/source/<flavor>/r/<build type(optional)>/<package>/R.java 重要的是你的R.java可以build/source/<flavor>/r/<build type(optional)>/<package>/R.java

You shouldn't need to manually interact with R.java at all. 您根本不需要手动与R.java交互。 It can be re-generated from the source code. 它可以从源代码重新生成。 Thus, it is likely that you won't have any problems -- R.java will be auto-generated and all will be well. 因此,您可能不会遇到任何问题 - R.java将自动生成并且一切都会很好。 If it isn't, try a rebuild of the project. 如果不是,请尝试重建项目。

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

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