How to generate R.java

后端 未结 11 1510
花落未央
花落未央 2020-12-10 03:57

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

相关标签:
11条回答
  • 2020-12-10 04:11
    • Open Android SDK Manager
    • Tick Tools that there are 3 packages of Android SDK Tools , delete and install them again.
    • When they are finished, please refresh your project in Package Explorer.

    You will see BuildConfig.java and R.java in /gen

    I think you wanna need that I recommend this comment

    Enjoy with your building app.

    0 讨论(0)
  • 2020-12-10 04:16

    Presume you have Android sdk. If you have.. just clean the project. R.java will be autogenerated.

    0 讨论(0)
  • 2020-12-10 04:17

    Hi I just faced the same problem. The file R.java is deleted an regenerated each time you clean the project. In my case there were some errors in one of .xml files and no R.java was generated. If you did not have Main.xml that might be the reason. anyway if you fix .xml problems R.java should be generated.

    0 讨论(0)
  • 2020-12-10 04:20

    Correct all errors in the Xml layouts, if the errors is only in the id attribute, change to other name an save, then type the original values, this solution works for me.

    0 讨论(0)
  • 2020-12-10 04:21

    If your build.xml includes the "-resource-src" target (which it will if you include $SDK_DIR/tools/main_rules.xml or lib_rules.xml) you can rebuild it with ant.

    0 讨论(0)
  • 2020-12-10 04:28

    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.

    0 讨论(0)
提交回复
热议问题