Cannot run program android-sdk build-tools aapt

We are using the Bitnami Jenkins image for Google Cloud. In trying to build an Android app using Gradle on Jenkins (and using the ‘android-sdk-manager’ gradle plugin to automatically download the Android SDK), I encountered the following stack trace (repeated 20 times) :

    java.io.IOException: Cannot run program "/home/tomcat/.android-sdk/build-tools/22.0.1/aapt": error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at com.android.builder.png.AaptProcess$Builder.start(AaptProcess.java:163)
	at com.android.builder.png.QueuedCruncher$1.creation(QueuedCruncher.java:106)
	at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:203)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.forkAndExec(Native Method)
	at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
	at java.lang.ProcessImpl.start(ProcessImpl.java:134)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 4 more

Looks like it might be related to these issues:

Since using Jenkins to build Android apps is a common use case, it would be really helpful if the Bitnami image were preconfigured to make this as straightforward as possible.

The ‘android-sdk-manager’ gradle plugin is at: https://github.com/JakeWharton/sdk-manager-plugin

As it turns out, the first stackoverflow link had a solution that did, in fact, work for me: sudo apt-get install lib32stdc++6 lib32z1

I think the bitnami image for jenkins should probably include this, since it’s such a common use case (and the symptoms are so baffling).

Hi @adommasch

Thanks for your workaround, but we don’t include these libraries in our stacks. Note that those are requirements for the plugins itself.

However, we will document how to configure it in our wiki.

Please, don’t hesitate to write us if you need anything else.

Regards,
Fran

Hi @adommasch

We are working on documenting this workaround in the wiki but we have a little information missing to reproduce the issue. What was the exact command that produced this error?

Please let us know in order to reproduce the issue. Thanks in advance.

Regards,

Juan

In a standard android app project, which uses gradle as its build system, the “aapt” tool is involved in building the apk’s. (Android functionality is brought into gradle via the “apply plugin: ‘com.android.application’” line. We also use “apply plugin: ‘android-sdk-manager’” to automatically download the appropriate version of the Android SDK to our jenkins box, to avoid manual intervention as much as possible.)

It turns out that “aapt” (at least the version we’re using) requires those additional libraries to be installed (mentioned in an earlier response) in order to actually function.

Hi @adommasch

Thank you very much. This information will be very helpful for improving our documentation.

Regards,

Juan

What if I’m on a Mac? How do I install these libraries then.

Hello @IgorGanapolsky

You can install System Libraries on OS X using the command “brew”. For example:

brew install lib32stdc++6 lib32z1 lib32z1-dev

I hope this information is useful for you. If you have any other question, please do not hesitate to let us know.

Best Regards,

Juan Ariza