如何生成R.java [英] How to generate R.java
问题描述
我从 Google 源代码下载了一些源代码.
I downloaded few source codes from Google source codes.
我在 Eclipse 上执行了它们,但没有创建 R.java
文件,因此我收到很多错误,说 R
无法解析.布局中也没有 main.xml
.还有一些其他的 XML 文件.如何执行这些程序?
I executed them on Eclipse but R.java
file is not created and therefore I got many errors saying that R
cannot be resolved. There is no main.xml
in layout too. Some other XML files are there. How can I execute these programs?
推荐答案
只要你有一个有效的 Android 项目,你就可以使用 aapt package
从资源中生成 R.java.这是示例用法(所有内容都应在一行中):
As long as you have a valid Android project, you can use aapt package
to generate the R.java from resources. Here's example usage (all should be in one line):
aapt package --non-constant-id -f -m -M <abs_path_to_AndroidManifest.xml>
-S <abs_path_to_res_dir> -I <abs_path_to_platforms_android.jar>
-J <abs_path_to_dir_that_should_contain_gen_R_java)
--generate-dependencies
通过使用 aapt 目标或简单地使用 exec 目标,可以使用 ANT 使上述内容可编写脚本.
The above can be made scriptable using ANT by using the aapt target or by simply using an exec target.
这篇关于如何生成R.java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!