ionic build android error

android, cordova, ionic-framework, windows-7-x64

Solution

I guess it's because you set ANDROID_HOME to the wrong path.

ANDROID_HOME must be set to the root of the android SDK, not to tools folder:

SET ANDROID_HOME=C:\adt-bundle-windows-x86_64-20140702\sdk

But the tools folder must be in the path.

SET PATH=%PATH%;%ANDROID_HOME%\tools

(of course use windows settings to set env vars, don't do it in cmd, that was just to explain more clearly)

Problem

I'm very new to the ionic framework,how ever I've cordova up and running in the windows 7 system but now I'm trying to build an android app with ionic framework and i followed the following steps ``` >npm install -g cordova >npm install -g ionic >ionic start resistance blank >cd resistance >ionic platform add android ``` Till here I'm doing good but when I run the command ``` >ionic build android ``` i get the following error ``` C:\Users\vishwant\resistance>ionic build android Running command: "C:\Program Files\nodejs\node.exe" C:\Users\vishwant\resistance\hooks\after_prepare\010_add_platform_class.js C:\Users\vishwant\resis tance add to body class: platform-android Running command: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:126 throw e; ^ Error: ENOENT, no such file or directory 'C:\adt-bundle-windows-x86_64-20140702\sdk\tools\tools\lib\build.template' at Object.fs.openSync (fs.js:432:18) at Object.fs.readFileSync (fs.js:289:15) at C:\Users\vishwant\resistance\platforms\android\cordova\lib\build.js:120:40 at _fulfilled (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:798:54) at self.promiseDispatch.done (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:827:30) at Promise.promise.promiseDispatch (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:760:13) at C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:574:44 at flush (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:108:17) at process._tickCallback (node.js:419:13) Error: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat: Command failed with exit code 8 at ChildProcess.whenDone (C:\Users\vishwant\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5) ``` I notice that the path is incorrect , but in the path variable I've set up correctly i.e till tools. Error: ENOENT, no such file or directory 'C:\adt-bundle-windows-x86_64-20140702\sdk\tools\tools\lib\build.template' Firstly,I don't understand why it's attaching one more tools\ and searching for the build.template Secondly, If i manual create that extra tools\ folder inside the tools\ (which i want to avoid) then this above error is gone but i will be shown ``` C:\Users\vishwant\resistance>ionic build android Running command: "C:\Program Files\nodejs\node.exe" C:\Users\vishwant\resistance\hooks\after_prepare\010_add_platform_class.js C:\Users\vishwant\resis tance add to body class: platform-android Running command: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat [Error: Please install Android target "android-19". Hint: Run "android" from your command-line to open the SDK manager.] Error: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat: Command failed with exit code 2 at ChildProcess.whenDone (C:\Users\vishwant\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5) ``` Since I've already installed android sdks and the targets 4.4W which is working fine for the cordova projects, I don't understand why it's failing for the ionic framework. Please correct me If I'm missing out something. Thanks

Original source