Reputation: 2783
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:
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.
Upvotes: 4
Views: 2903
Reputation: 2783
After another couple of hours of investigation I finally found a workaround!
I was always wondering why I was able to build it locally on my machine, but not with Jenkins or even not with ANT from command line on the remote server where Jenkins runs. . So instead of executing ANT with...
ant -Dsdk.dir=<YOUR SDK DIR> -Dtested.project.dir=<PATH TO YOUR PROJECT UNDER TEST> clean debug install test
...
I set the tested.project.dir property within the ant.properties file to the correct path on the server and checked this in to the source code repository. Then I removed the property from the list of arguments for ANT in Jenkins, so that Jenkins now only executes
ant -Dsdk.dir=<YOUR SDK DIR> clean debug install test
And finally it works.
(Of course it's genarally no good practice to check specific path information into the repository. But finally it's working...)
Upvotes: 1
Reputation: 24314
"As reported, the issue should actually have been fixed, but I am still facing the described problem."
The issue you refer to (issue 21108: Testing library project broken with SDK Tools r14) isn't fixed. This is similar to issue 21304: "ant debug installt" should work for test projects. which will not be fixed.
Here is the workaround from Joe Bowbeer:
Remove tested.project.dir
from ant.properties
Add run-tests
target to 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>
Run tests using command line:
$ ant debug install run-tests
In other words, if you were using one single installt
target you need to change that.
Upvotes: 2