Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

android - How to generate R.java

I downloaded few source codes from Google source codes.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

The above can be made scriptable using ANT by using the aapt target or by simply using an exec target.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...