user147
user147

Reputation: 1310

Cordova Build command doesn't work any more for android

this is what I get, an output from command line when I try to build cordova application:

C:\wamp\tests\cortest>cordova build
Generating config.xml from defaults for platform "android"
Preparing android project
Compiling app on platform "android" via command "cmd" /c C:\wamp\te
sts\cortest\platforms\android\cordova\build
Error: An error occurred while building the android project.Error executing "ant
 debug -f "C:\wamp\tests\cortest\platforms\android\build.xml"":
BUILD FAILED
C:\Program Files (x86)\Android\android-studio\sdk\tools\ant\build.xml:601: The f
ollowing error occurred while executing this line:
C:\Program Files (x86)\Android\android-studio\sdk\tools\ant\build.xml:720: The f
ollowing error occurred while executing this line:
C:\Program Files (x86)\Android\android-studio\sdk\tools\ant\build.xml:734: Compi
le failed; see the compiler error output for details.

Total time: 1 second


    at ChildProcess.<anonymous> (C:\Users\John\AppData\Roaming\npm\node_modules\
cordova\src\compile.js:65:22)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

And this is my config file :

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.foundation.app" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>FoundationMobile</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="[email protected]" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
</widget>

I have Windows 7, 64bit. Not sure is it important. Any idea what is going on, why can not I build it any more? It was working before I update Android SDK with android manager.

Thank you so much in advance!

Added on 23/02/2014, project and sdk paths are different now, because I have reinstalled sdk, and created fresh projects, but error is the same.

C:\wamp\tests\cordova-test>cordova -d build cordova library for "android" already exists. No need to download. Continuing. Generating config.xml from defaults for platform "android" Calling plugman.prepare for platform "android" Preparing android project Processing configuration changes for plugins. Iterating over installed plugins: [] Writing out cordova_plugins.js... Wrote out Android application name to "CordovaTest" Wrote out Android package name to "com.foundation.app" Compiling app on platform "android" via command "cmd" /c C:\wamp\te sts\cordova-test\platforms\android\cordova\build exec: ant clean -f "C:\wamp\tests\cordova-test\platforms\android\bu ild.xml"

[ 'ant clean -f "C:\\wamp\\tests\\cordova-test\\platforms\\androi
d\\build.xml"',
  null,
  'Buildfile: C:\\wamp\\tests\\cordova-test\\platforms\\android\\
build.xml\r\n\r\n-check-env:\r\n [checkenv] Android SDK Tools Revision 22.3.0\r\
n [checkenv] Installed at C:\\adt-bundle-windows-x86_64-20131030\\sdk\r\n\r\n-se
tup:\r\n     [echo] Project Name: CordovaTest\r\n  [gettype] Project Type: Appli
cation\r\n\r\n-pre-clean:\r\n\r\nclean:\r\n   [delete] Deleting directory C:\\wam
p\\tests\\cordova-test\\platforms\\android\\bin\r\n   [delete] D
eleting directory C:\\wamp\\tests\\cordova-test\\platforms\\andro
id\\gen\r\n[getlibpath] Library dependencies:\r\n[getlibpath] \r\n[getlibpath] -
-----------------\r\n[getlibpath] Ordered libraries:\r\n\r\nnodeps:\r\n\r\n-chec
k-env:\r\n [checkenv] Android SDK Tools Revision 22.3.0\r\n [checkenv] Installed
 at C:\\adt-bundle-windows-x86_64-20131030\\sdk\r\n\r\n-setup:\r\n     [echo] Pr
oject Name: CordovaLib\r\n  [gettype] Project Type: Android Library\r\n\r\n-pre-
clean:\r\n\r\nclean:\r\n   [delete] Deleting directory C:\\wamp\\
tests\\cordova-test\\platforms\\android\\CordovaLib\\bin\r\n   [delete] Deleting
 directory C:\\wamp\\tests\\cordova-test\\platforms\\android\\Cor
dovaLib\\gen\r\n\r\nBUILD SUCCESSFUL\r\nTotal time: 0 seconds\r\n',
  '' ]

exec: ant debug -f "C:\wamp\tests\cordova-test\platforms\android\bu
ild.xml"

[ 'ant debug -f "C:\\wamp\\tests\\cordova-test\\platforms\\androi
d\\build.xml"',
  { [Error: Command failed:
  BUILD FAILED
  C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:601: The followi
ng error occurred while executing this line:
  C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:720: The followi
ng error occurred while executing this line:
  C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:734: Compile fai
led; see the compiler error output for details.

  Total time: 2 seconds
  ] killed: false, code: 1, signal: null },
  'Buildfile: C:\\wamp\\tests\\cordova-test\\platforms\\android\\
build.xml\r\n\r\n-set-mode-check:\r\n\r\n-set-debug-files:\r\n\r\n-check-env:\r\
n [checkenv] Android SDK Tools Revision 22.3.0\r\n [checkenv] Installed at C:\\a
dt-bundle-windows-x86_64-20131030\\sdk\r\n\r\n-setup:\r\n     [echo] Project Nam
e: CordovaTest\r\n  [gettype] Project Type: Application\r\n\r\n-set-debug-mode:\
r\n\r\n-debug-obfuscation-check:\r\n\r\n-pre-build:\r\n\r\n-build-setup:\r\n[get
buildtools] Using latest Build Tools: 19.0.2\r\n     [echo] Resolving Build Targ
et for CordovaTest...\r\n[gettarget] Project Target:   Android 4.4.2\r\n[gettarg
et] API level:        19\r\n     [echo] ----------\r\n     [echo] Creating outpu
t directories if needed...\r\n    [mkdir] Created dir: C:\\wamp\\root\\
tests\\cordova-test\\platforms\\android\\bin\r\n    [mkdir] Created dir: C:\\wamp
\\tests\\cordova-test\\platforms\\android\\bin\\res\r\n    [mkdi
r] Created dir: C:\\wamp\\tests\\cordova-test\\platforms\\android
\\bin\\rsObj\r\n    [mkdir] Created dir: C:\\wamp\\tests\\cordova
-test\\platforms\\android\\bin\\rsLibs\r\n    [mkdir] Created dir: C:\\wamp\\tes
ts\\cordova-test\\platforms\\android\\gen\r\n    [mkdir] Created
dir: C:\\wamp\\tests\\cordova-test\\platforms\\android\\bin\\clas
ses\r\n    [mkdir] Created dir: C:\\wamp\\tests\\cordova-test\\pl
atforms\\android\\bin\\dexedLibs\r\n     [echo] ----------\r\n     [echo] Resolv
ing Dependencies for CordovaTest...\r\n[dependency] Library dependencies:\r\n[de
pendency] \r\n[dependency] ------------------\r\n[dependency] Ordered libraries:
\r\n[dependency] \r\n[dependency] ------------------\r\n     [echo] ----------\r
\n     [echo] Building Libraries with \'debug\'...\r\n\r\nnodeps:\r\n\r\n-set-mo
de-check:\r\n\r\n-set-debug-files:\r\n\r\n-check-env:\r\n [checkenv] Android SDK
 Tools Revision 22.3.0\r\n [checkenv] Installed at C:\\adt-bundle-windows-x86_64
-20131030\\sdk\r\n\r\n-setup:\r\n     [echo] Project Name: CordovaLib\r\n  [gett
ype] Project Type: Android Library\r\n\r\n-set-debug-mode:\r\n\r\n-debug-obfusca
tion-check:\r\n\r\n-pre-build:\r\n\r\n-build-setup:\r\n[getbuildtools] Using lat
est Build Tools: 19.0.2\r\n     [echo] Resolving Build Target for CordovaLib...\
r\n[gettarget] Project Target:   Android 4.4.2\r\n[gettarget] API level:
19\r\n     [echo] ----------\r\n     [echo] Creating output directories if neede
d...\r\n    [mkdir] Created dir: C:\\wamp\\tests\\cordova-test\\p
latforms\\android\\CordovaLib\\bin\r\n    [mkdir] Created dir: C:\\wamp\\tests
\\cordova-test\\platforms\\android\\CordovaLib\\bin\\res\r\n    [mk
dir] Created dir: C:\\wamp\\tests\\cordova-test\\platforms\\andro
id\\CordovaLib\\bin\\rsObj\r\n    [mkdir] Created dir: C:\\wamp\\root\\
tests\\cordova-test\\platforms\\android\\CordovaLib\\bin\\rsLibs\r\n    [mkdir]
Created dir: C:\\wamp\\tests\\cordova-test\\platforms\\android\\C
ordovaLib\\gen\r\n    [mkdir] Created dir: C:\\wamp\\tests\\cordo
va-test\\platforms\\android\\CordovaLib\\bin\\classes\r\n    [mkdir] Created dir
: C:\\wamp\\tests\\cordova-test\\platforms\\android\\CordovaLib\\
bin\\dexedLibs\r\n     [echo] ----------\r\n     [echo] Resolving Dependencies f
or CordovaLib...\r\n[dependency] Library dependencies:\r\n[dependency] No Librar
ies\r\n[dependency] \r\n[dependency] ------------------\r\n\r\n-code-gen:\r\n[me
rgemanifest] Merging AndroidManifest files into one.\r\n[mergemanifest] Manifest
 merger disabled. Using project manifest only.\r\n     [echo] Handling aidl file
s...\r\n     [aidl] No AIDL files to compile.\r\n     [echo] ----------\r\n
[echo] Handling RenderScript files...\r\n     [echo] ----------\r\n     [echo] H
andling Resources...\r\n     [aapt] Generating resource IDs...\r\n     [echo] --
--------\r\n     [echo] Handling BuildConfig class...\r\n[buildconfig] Generatin
g BuildConfig class.\r\n\r\n-pre-compile:\r\n\r\n-compile:\r\n    [javac] Compil
ing 73 source files to C:\\wamp\\tests\\cordova-test\\platforms\\
android\\CordovaLib\\bin\\classes\r\n    [javac] C:\\wamp\\root\\tests\
\cordova-test\\platforms\\android\\CordovaLib\\src\\com\\squareup\\okhttp\\inter
nal\\http\\HttpEngine.java:95: error: cannot access RouteSelector\r\n    [javac]
   protected RouteSelector routeSelector;\r\n    [javac]             ^\r\n    [j
avac]   bad source file: C:\\wamp\\tests\\cordova-test\\platforms
\\android\\CordovaLib\\src\\com\\squareup\\okhttp\\internal\\http\\RouteSelector
.java\r\n    [javac]     file does not contain class com.squareup.okhttp.interna
l.http.RouteSelector\r\n    [javac]     Please remove or make sure it appears in
 the correct subdirectory of the sourcepath.\r\n',
  '\r\nBUILD FAILED\r\nC:\\adt-bundle-windows-x86_64-20131030\\sdk\\tools\\ant\\
build.xml:601: The following error occurred while executing this line:\r\nC:\\ad
t-bundle-windows-x86_64-20131030\\sdk\\tools\\ant\\build.xml:720: The following
error occurred while executing this line:\r\nC:\\adt-bundle-windows-x86_64-20131
030\\sdk\\tools\\ant\\build.xml:734: Compile failed; see the compiler error outp
ut for details.\r\n\r\nTotal time: 2 seconds\r\n' ]

Error executing "ant debug -f "C:\wamp\tests\cordova-test\platforms
\android\build.xml"":
BUILD FAILED
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:601: The following
 error occurred while executing this line:
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:720: The following
 error occurred while executing this line:
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:734: Compile faile
d; see the compiler error output for details.

Total time: 2 seconds


child_process.spawn(cmd,[/c, C:\wamp\tests\cordova-test\platforms\a
ndroid\cordova\build]) = 2
Error: An error occurred while building the android project.Error executing "ant
 debug -f "C:\wamp\tests\cordova-test\platforms\android\build.xml""
:
BUILD FAILED
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:601: The following
 error occurred while executing this line:
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:720: The following
 error occurred while executing this line:
C:\adt-bundle-windows-x86_64-20131030\sdk\tools\ant\build.xml:734: Compile faile
d; see the compiler error output for details.

Total time: 2 seconds


    at ChildProcess.<anonymous> (C:\Users\Ivan\AppData\Roaming\npm\node_modules\
cordova\src\compile.js:65:22)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

C:\wamp\tests\cordova-test>

Upvotes: 1

Views: 6060

Answers (4)

valverde93
valverde93

Reputation: 1698

Try to get latest version of android platform.

cordova platform update android

It's worked for me

Upvotes: 1

kararade
kararade

Reputation: 560

I have too a laptop with Windows 7 64 bits and I solved this problem doing the following

  • Download the last version of ANT from http://ant.apache.org/
  • Unzip and put the files in the correct place in the disk
  • Copy the absolute direction where is the bin folder of the ANT in the Windows PATH variable.

    I.E. in my case. D:\apache-ant-1.9.4\bin

  • In the CMD check if the ant -version is working. This should display the version of the ANT downloaded ( If is not working check the PATH variable again, before do the next step )

  • In the CMD go to the cordova project folder and run again the cordova build android. If the previous step is working you should build without problem your project. If your project is an Ionic project you should run here ionic build android and the result should be the same.

I hope this help.

Regards!

Upvotes: 2

user147
user147

Reputation: 1310

Problem was in enviroment variable path, ANDROID_HOME was pointing to : "C:\Program Files (x86)\Android\android-studio\sdk", I have just added a PROGRAM_FILES_86 to point to : C:\Program Files (x86) and set again ANDROID_HOME path again with PROGRAM_FILES_86 variable. That has solved the issue.

Upvotes: 0

sr77in
sr77in

Reputation: 317

try ant -v in your terminal and make sure it's above 1.8. Cordova requires that. Also check path is given correct for Ant, Android-SDK/tools, and Android-SDK/platformtools

To debug exact issue try $Cordova build android --verbose

Upvotes: 0

Related Questions