2016-02-23 114 views
0

我需要通过使用命令行来构建R.JAVA文件。有几种IDE的使用方法,但是有什么方法或代码可以通过命令行生成R.JAVA文件吗?手动生成R.JAVA文件

+0

@让BaptisteYunès不看是,这个问题的答案使用一个IDE – flakes

+0

错了,这个问题的答案建议你手动使用蚂蚁,仔细阅读。 –

回答

2

看看this tutorial

为了让应用程序源代码,以便能够将res /目录中访问 资源,一个名为R.java(用于 资源)类被创建。

使用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 

R.java在src /树内的目标位置是通过清单文件的包属性确定。

当选项有:

-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 
+0

可否请详细解释(如完整代码) –