cordova build android error

Asked by At

When i do the cordova build android in cmd, it gives an error:

the output is:

D:\Projects\myprojectfortest-clone>cordova build android
Running command: D:\Projects\myprojectfortest-clone\platforms\android\cordova\build.b
at
Buildfile: D:\Projects\myprojectfortest-clone\platforms\android\build.xml

BUILD FAILED
D:\Projects\myprojectfortest-clone\platforms\android\build.xml:90: Cannot find D:\nb1
8908\Android22SDK\adt-bundle-windows-x86_64-20130917\sdk\tools\ant\build.xml imp
orted from D:\Projects\myprojectfortest-clone\platforms\android\build.xml

Total time: 0 seconds
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,D:\Projects\mysafari
com-clone\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant
-gen
Error: D:\Projects\myprojectfortest-clone\platforms\android\cordova\build.bat: Comman
d failed with exit code 2
    at ChildProcess.whenDone (C:\Users\MyUser\AppData\Roaming\npm\node_modules\
cordova\src\superspawn.js:126:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Process.ChildProcess._handle.onexit (child_process.js:820:5)

i set some path Environment variables :

ANDROID_HOME C:\Users\nb14696\AppData\Local\Android\android-sdk\tools ANDROID_PLATFORM_TOOLS C:\Users\nb14696\AppData\Local\Android\android-sdk\platform-tools ANDROID_PLATFORMS C:\Users\nb14696\AppData\Local\Android\android-sdk\platforms Path C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Intel\Services\IPT\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft Team Foundation Server 2012 Power Tools\;C:\Program Files (x86)\Microsoft Team Foundation Server 2012 Power Tools\Best Practices Analyzer\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\nodejs\;C:\Program Files (x86)\Java\jdk1.7.0_55\bin;%ANDROID_HOME%;%ANT_HOME%\bin;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\TortoiseHg\;C:\Program Files\Mercurial\;C:\apache-ant-1.9.3\bin;%ANDROID_PLATFORM_TOOLS%;%ANDROID_PLATFORMS%;

I have instaled the Android SDK version 2.2 and 4.4.2, what is wrong?

2 Answers

3
Paullo On

I knew this is kind of late but I hope it will help others. First I will like to correct some error I think I found in your path,

ANDROID_HOME C:\Users\nb14696\AppData\Local\Android\android-sdk\tools

it should read

ANDROID_HOME C:\Users\nb14696\AppData\Local\Android\android-sdk

Though you must have

%ANDROID_HOME%/tools and %ANDROID_HOME%/platform-tools

must be available in your path. Once you settle that excute

android list target

to confirm that you have your required targets. Then try your build command again

0
Aniruddha Pondhe On

I had similar issue.

The issue was with the incompatibility of the Ant version with my Java version.

Ant version I have is 1.8.4. Initially, I had JDK 8 - which supports only Ant 1.9 & greater

Therefore, I uninstalled JDK8 and reverted back to JDK7

Yes, I could have rather updated Ant itself. That is also an option. However, I particularly needed Ant1.8