4

When I try to build an Android test project on Jenkins I receive the following error message:

BUILD FAILED
C:\Progra~1\android-sdk\tools\ant\build.xml:444: The
   following error occurred while executing this line:
C:\Progra~1\android-sdk\tools\ant\build.xml:444: subant task calling
   its own parent target.

This seems somehow to be a known issue (https://code.google.com/p/android/issues/detail?id=21108, https://wiki.jenkins-ci.org/pages/viewpage.action?pageId=58917193). As reported, the issue should actually have been fixed, but I am still facing the described problem.

I am running Jenkins on a Windows Server, have the latest Android tools installed (SDK tools v22.0.1, platform and build tools v17) and utilizing Ant 1.9.0..

The project structure is:

  • Project A
  • Test Project for Project A

I created a dedicted build job on Jenkins for both of them. The build.xml files for both projects have been created with the "android update" command (as described in the Android specs). So they both are referencing the build.xml from the android-sdk/tools/ant folder. Refering to the Apache Ant specs for subant (http://ant.apache.org/manual/Tasks/subant.html) this might be the source of the failure?!

This task must not be used outside of a target if it invokes the same build file it is part of.

Has anyone of you encountered similar issues? Any ideas how to solve it?

Thanks in advance for your help.

4

2 回答 2

2

“据报道,这个问题实际上应该已经解决了,但我仍然面临着所描述的问题。”

您提到的问题(问题 21108:测试库项目被 SDK Tools r14 破坏)未修复。这类似于问题 21304:“ant debug installt”应该适用于测试项目。不会被修复。

这是Joe Bowbeer 的解决方法

  1. tested.project.dir从中删除ant.properties

  2. run-tests目标添加到build.xml

    <!-- SDK Tools r15 workaround -->
    <property name="tested.manifest.package" value="com.example.test" />
    
    <target name="run-tests">
     <echo>Running tests...</echo>
     <exec executable="${adb}" failonerror="true">
       <arg line="${adb.device.arg}" />
       <arg value="shell" />
       <arg value="am" />
       <arg value="instrument" />
       <arg value="-w" />
       <arg value="${tested.manifest.package}/${test.runner}" />
     </exec>
    

  3. 使用命令行运行测试:

    $ ant debug install run-tests
    

换句话说,如果你使用的是一个单一的installt目标,你需要改变它。

于 2013-07-17T20:44:28.407 回答
1

经过几个小时的调查,我终于找到了解决方法!

我一直想知道为什么我能够在我的机器上本地构建它,但不能使用 Jenkins,甚至不能使用 Jenkins 运行的远程服务器上的命令行中的 ANT。. 所以不是用...执行ANT

ant -Dsdk.dir=<YOUR SDK DIR> -Dtested.project.dir=<PATH TO YOUR PROJECT UNDER TEST> clean debug install test

...

我将ant.properties 文件中的tested.project.dir 属性设置为服务器上的正确路径,并将其签入到源代码存储库中。然后我从 Jenkins 中 ANT 的参数列表中删除了该属性,以便 Jenkins 现在只执行

ant -Dsdk.dir=<YOUR SDK DIR> clean debug install test

最后它起作用了。

(当然,将特定路径信息检查到存储库中通常不是一个好的做法。但最终它正在工作......)

于 2013-09-27T08:21:07.100 回答