Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova build fails, can't find ${appt}

The command cordova build android fails with the following output

BUILD FAILED
F:\Programs\SDK\tools\ant\build.xml:597: The following error occurred while executing this line:
F:\Programs\SDK\tools\ant\build.xml:649: The following error occurred while executing this line:
F:\Programs\SDK\tools\ant\build.xml:694: Execute failed: java.io.IOException: Cannot run program
"F:\code\asistenciaBT\platforms\android\CordovaLib\${aapt}" 
(in directory   "F:\code\asistenciaBT\platforms\android\CordovaLib"): CreateProcess error=2, 
El sistema no puede encontrar el archivo especificado

Meaning, as far as I can tell, that ant can't find the aapt file. Ant is installed:

ant -version
Apache Ant(TM) version 1.9.4 compiled on April 29 2014

ANDROID_HOME and PATH are correctly set as well. I have made cordova work on this system before, now it just refuses to.

Should cordova be looking for appt in the project directory? Shouldn't it be looking on ANDROID_HOME/build_tools ?

Some further detail, in case is needed:

npm -v
2.7.4

node -v
v0.12.2

cordova -v
5.1.1

os: windows 8.1 pro 64 bits

Project was cloned from github so it might have some inherited incompatibility somewhere.

EDIT:

Just tested 'cordova build' on a new project and it fails with the same error.

like image 351
jlasarte Avatar asked Jun 12 '15 14:06

jlasarte


People also ask

How to create your first app in Cordova?

Create your first Cordova app 1 Installing the Cordova CLI. The Cordova command-line tool is distributed as an npm package. ... 2 Install pre-requisites for building. To build and run apps, you need to install SDKs for each platform you wish to target. ... 3 Using merges to Customize Each Platform. ... 4 Updating Cordova and Your Project. ...

How to find the latest version of Cordova?

For example, an app can incorporate a back button graphic into the iOS interface, stored in merges/ios/img/back_button.png, while the Android version can instead capture backbutton events from the corresponding hardware button. Run cordova -v to see which version is currently running. To find the latest released cordova version, you can run:

How do I find plug-ins in Cordova?

Plugins are typically hosted on npm and you can search for them on the plugin search page. Some key APIs are provided by the Apache Cordova open source project and these are referred to as Core Plugin APIs. You can also use the CLI to launch the search page:

What does the Cordova create script generate?

By default, the cordova create script generates a skeletal web-based application whose home page is the project's www/index.html file. All subsequent commands need to be run within the project's directory, or any subdirectories:


3 Answers

It looks like ant commands are broken in Android SDK 24.3, which cordova build is using. I downgraded to previous release (24.2.0) and ant works fine now.

You can download previous SDK from: http://dl-ssl.google.com/android/repository/tools_r24.2-windows.zip

EDIT: There is better solution, See kartikeya's answer below: https://stackoverflow.com/a/31603358/1453578

Also, if you're not using cordova but relying on ant to build your android project, just move to gradle already.

like image 89
Pranav Gupta Avatar answered Sep 28 '22 18:09

Pranav Gupta


no need to downgrade or upgrade your SDK. Follow this step. Go to .../sdk/tools/ant/build.xml and find there:

    <!-- find location of build tools -->
    <getbuildtools name="android.build.tools.dir" verbose="${verbose}" />

add below the lines:

    <property name="aidl" location="${android.build.tools.dir}/aidl${exe}" />
    <property name="aapt" location="${android.build.tools.dir}/aapt${exe}" />
    <property name="dx" location="${android.build.tools.dir}/dx${bat}" />
    <property name="zipalign" location="${android.build.tools.dir}/zipalign${exe}" />
like image 27
Kartikeya Mishra Avatar answered Sep 28 '22 18:09

Kartikeya Mishra


SDK is broken ... downgrade to previous version ! i.e , ant version 1.9.4 TO Ant 1.9.5 or downgrade android skd tools

like image 30
OverLink Avatar answered Sep 28 '22 20:09

OverLink