手动生成R.JAVA文件

时间:2016-02-23 17:49:57

标签: java android bash command-line apk

我需要使用命令行构建R.JAVA文件。通过使用多个IDE可以使用各种方法。但是有没有方法或代码可以使用命令行生成R.JAVA文件?

1 个答案:

答案 0 :(得分:2)

查看this tutorial

  

为了使应用程序源代码能够访问   res /目录中的资源,一个名为R.java的类(for   资源)已创建。

     

使用Android Asset Packaging Tool(aapt)创建R.java文件:

ANDROID_HOME/platform-tools/aapt
                        package
                        -v
                        -f
                        -m
                        -S DEV_HOME/res
                        -J DEV_HOME/src
                        -M DEV_HOME/AndroidManifest.xml
                        -I ANDROID_HOME/platforms/android-X/android.jar
     

src / tree中R.java的目标位置由清单文件的package属性决定。

选项如下:

-v  verbose output
-f  force overwrite of existing files
-m  make package directories under location specified by -J
-S  directory in which to find resources.  Multiple directories will be scanned
    and the first match found (left to right) will take precedence.
-J  specify where to output R.java resource constant definitions
-M  specify full path to AndroidManifest.xml to include in zip
-I  add an existing package to base include set  

参数是:

DEV_HOME - the project directory
ANDROID_HOME - Android Software Development Kit installation location
相关问题