Building an Android test project with Jenkins fails due to sub-item error

When I try to create a test project for Android on Jenkins, I get 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 like 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 problem should be fixed, but I still encounter the described problem.

I run Jenkins on Windows Server, install the latest Android tools (SDK tools v22.0.1, platform and build tools v17) and using Ant 1.9.0 ..

Project Structure:

  • Project A
  • Test Project for Project A

I created an assembly task for Jenkins for both of them. The build.xml files for both projects were created using the "android update" command (as described in the Android specifications). Therefore, they both refer to the build.xml file from the android-sdk / tools / ant folder. Referring to the Apache Ant specs for subant ( http://ant.apache.org/manual/Tasks/subant.html ), can this be a source of failure ?!

This task should not be used outside the target if it calls the same assembly file as part.

Have any of you encountered similar problems? Any ideas how to solve it?

Thanks in advance for your help.

+4
source share
2 answers

After several more hours of investigation, I finally found a workaround!

I was always wondering why I was able to create it locally on my machine, but not with Jenkins or even not with ANT from the command line on the remote server where Jenkins works. Therefore, instead of performing ANT with ...

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

...

I set the test.project.dir property in the ant.properties file to the correct path on the server and checked this in the source code repository. Then I removed the property from the argument list for ANT in Jenkins, so now Jenkins only performs

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

And finally, it works.

(Of course, there is no good practice for checking specific path information in the repository, but finally it works ...)

+1
source

"Reportedly, the problem needs to be fixed, but I am still facing the described problem."

The problem you are referring to ( issue 21108: Test library project, broken into SDK Tools r14 ) has not been fixed. This is similar to issue 21304: "ant debug installt" should work for test projects. which will not be fixed.

Here is a 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> 

  • Running tests using the command line:

     $ ant debug install run-tests 

In other words, if you used a single installt target, you need to change it.

+2
source

Source: https://habr.com/ru/post/1490895/


All Articles