`ant` is looking for `aapt` in project directory?

246 views Asked by At

I am lately having problems with a build process that has been working for months now - I may have updated the Android build tools since the last working build, but I am not sure.

In any case

ant -Dsdk.dir=$ANDROID_HOME -Djava.source=7 -Djava.target=7 clean release

is failing with the following message:

/home/dmta/development/android-sdk-linux/tools/ant/build.xml:694: Execute failed: java.io.IOException:
Cannot run program "/home/dmta/EclipseProjects/MyProject/Hawk/${aapt}"
(in directory "/home/dmta/EclipseProjects/MyProject/Hawk"): error=2,
No such file or directory

Where Hawk is a library project I am using.

What could be wrong here?

I can build the program from Eclipse but I need to use the ant build for proguard.

2

There are 2 answers

2
S P On

the AAPt location is changed in the latest update. Copy the lib/dx and aapt : these two files back to platform-tools. Also try adding the tools path if not there already, example:

<!-- tools location -->
<property name="android.tools.dir" location="${sdk.dir}/tools" />
<property name="android.platform.tools.dir" location="${sdk.dir}/platform-tools" />
<property name="android.buildtools.dir" location="${sdk.dir}/build-tools/22.0.1" />
<condition property="exe" value=".exe" else="">    <os family="windows" />    </condition>
<condition property="bat" value=".bat" else="">    <os family="windows" />    </condition>
<property name="adb" location="${android.platform.tools.dir}/adb${exe}" />
<property name="lint" location="${android.tools.dir}/lint${bat}" />
<property name="zipalign" location="${android.buildtools.dir}/zipalign${exe}" />
<property name="aidl" location="${android.platform.tools.dir}/aidl${exe}" />
<property name="aapt" location="${android.buildtools.dir}/aapt${exe}" />
<property name="dx" location="${android.buildtools.dir}/dx${bat}" />
<property name="renderscript" location="${android.buildtools.dir}/llvm-rs-cc${exe}"/>
<property name="lint" location="${android.tools.dir}/lint${bat}" />
0
david.mihola On

With the help of S P's initial answer I was able to get this to work.

It is worth noting that my question, or at least the question title is misleading: At first I thought that ant was actually looking for the executable aapt inside the project folder.

However, on closer inspection it actually is looking for ${aapt}. This indicates that ant is trying to use the value of a property called "aapt", which is however not set. So instead of building any sensible executable path it just appends the name to it's current working directory - or something like that.

In any case, all I needed to to was insert the following lines into my ~/development/android-sdk-linux/tools/ant/build.xml file:

<property name="android.buildtools.dir" location="${sdk.dir}/build-tools/22.0.1" />
<property name="aapt" location="${android.buildtools.dir}/aapt" />
<property name="aidl" location="${android.buildtools.dir}/aidl" />
<property name="dx" location="${android.buildtools.dir}/dx" />
<property name="zipalign" location="${android.buildtools.dir}/zipalign" />

That's because as soon as I told ant where to find aapt it complained about aidl, dx and zipalign.