Android Ant构建在具有两个源文件夹的项目上

Nic*_*ckT 8 ant android

我有一个带有链接源文件夹的项目.此项目依赖于另一个(远程服务)项目,因此通过远程接口传递的aidl文件和类common_src位于两个项目之间共享的链接文件夹中.这项工作与Eclipse构建完全一致,(一个源文件,两个项目,一个项目中的更改反映在另一个项目中,就像它应该的那样).

我现在想从命令行执行Ant构建.我设法使用build.xmlSDK工具中的示例,在所有目标上构建了一个带有单个src目录的项目.它会ant_rules_r3.xml自动导入,一旦定义source.dirout.dir在其中定义,build.properties它们都相当轻松.

转到带有srccommon_src文件夹的项目,我无法构建它.首先,我将编译目标及其所依赖的所有内容剪切并粘贴到build.xml上面的设置任务中.我并将所限定的元件common_srcbuild.properties,并加入如下所示的最后一行-compile target(从复制ant_rules_r3.xml)到build xml:

  <src path="${source.absolute.dir}" />
  <src path="${gen.absolute.dir}" />
  <src path="${common_src}" /><!--ADDED-->
Run Code Online (Sandbox Code Playgroud)

它在构建过程中进一步发展 - 它可以在common_src中找到.java文件,但不能找到.aidl文件.毫不奇怪,我意识到,援助是一个单独的目标.然后我补充道

<src path="${common_src}" /> 
Run Code Online (Sandbox Code Playgroud)

到构建xml中的-aidl目标,它失败了:

BUILD FAILED
C:\dev\projects\Eclipse\AndroidWorkspace\MapProject\build.xml:77: aidl doesn't
 support the nested "src" element.
Run Code Online (Sandbox Code Playgroud)

所以这让我很好,真的卡住了.理想情况下,我只想修改build.properties文件以包含common_src并将其传递给ant_rules_r3.xml,但我想不出这样做的方法.如果有人能够建议如何做到,我将非常感激.

小智 16

我有一个类似的问题,但似乎已通过我的build.properties文件中的以下设置解决了我:

source.dir = src;../other_project/src
Run Code Online (Sandbox Code Playgroud)

我使用相对路径将我的src链接到other_project,但您应该能够使用绝对路径.如果这样做,您应该将其放在local.properties中.

注意:根据build.properties中的注释,如果我的SDK版本<2.0,我会使用它:

source-folder = src;../other_project/src
Run Code Online (Sandbox Code Playgroud)


Nic*_*ckT 6

如果有任何兴趣,我想我会回答我现在已经解决的问题.

1)我在build.properties中定义了common_src

2)添加了该行

<src path="${common_src}"
Run Code Online (Sandbox Code Playgroud)

在设置上方的build.xml中的覆盖编译目标中(加上通过从ant_rules_r3.xml剪切/粘贴来覆盖它所依赖的所有目标)3)在构建中添加了与'aidl'相同的新目标'aidl2'. xml,但有行

<source path="${common_src}" 代替

<source path="${source.absolute.dir}" .
Run Code Online (Sandbox Code Playgroud)

制造援助取决于aidl2.覆盖所有援助依赖的目标.

我还添加了以下行:

key.store=xxxxxxxxxxxxx
key.alias=xxxxxxxxxxxxx
key.store.password=xxxxxxxxxxxxx
key.alias.password=xxxxxxxxxxxxx
Run Code Online (Sandbox Code Playgroud)

到build.xml自动输入密码.我最后添加了一个install_release目标来进行自动一个命令构建,rease和安装过程.


mba*_*mba 6

我无法评论,因为我没有足够的声誉,但如果添加源文件夹与之前的答案一起工作,则在构建jar时会失败:


compile:
    [javac] Compiling 463 source files to /home/xxx/documents/eclipse/xxx/deploy/xxx/bin/classes
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] Creating empty /home/xxx/documents/eclipse/xxx/deploy/xxx/bin/classes/fr/xxx/android/socialintegration/facebook/package-info.class
     [echo] Creating library output jar file...

BUILD FAILED
/home/xxx/applis/android/android-sdk-linux/tools/ant/build.xml:570: The following error occurred while executing this line:
/home/xxx/applis/android/android-sdk-linux/tools/ant/build.xml:680: The following error occurred while executing this line:
/home/xxx/applis/android/android-sdk-linux/tools/ant/build.xml:744: /home/xxx/documents/eclipse/xxx/deploy/xxx/src;../xxxdata/src does not exist.

故障部分在jar的构建中,使用source.absolute.dir作为filset,对于ant无效.

但我现在没有任何解决方法,我不明白为什么其他人设法让它工作......(我也使用sdk r20)