Thursday, May 14, 2015

[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.] Error: /Users/Naushad/IonicProjects/IonicApp/platforms/android/cordova/build: Command failed with exit code 2 at ChildProcess.whenDone (/usr/local/lib/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:766:16) at Process.ChildProcess._handle.onexit (child_process.js:833:5)


sudo ionic build android

[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
Error: /Users/Naushad/IonicProjects/IonicApp/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/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:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)

to solve this i use following steps in terminal :

sudo chown -R Naushad /usr/local/lib/node_modules/cordova

still have same error than i do follwing step

export PATH=$PATH:/users/Naushad/android-sdks/tools
 then i got below error  :)
[Error: Please install Android target: "android-22".

Hint: Open the SDK manager by running: /users/Naushad/android-sdks/tools/android
You will require:
1. "SDK Platform" for android-22
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]
Error: /Users/Naushad/IonicProjects/IonicApp/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/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:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)

then  I goto my Android sdk manager and update my android-22 and bam!! its work :)
Now I can build my ionic app for android :)

:preDexDebug
:dexDebug
:processDebugJavaRes UP-TO-DATE
:validateDebugSigning
:packageDebug
:zipalignDebug
:assembleDebug
:cdvBuildDebug

BUILD SUCCESSFUL

In short you need these two commands

sudo chown -R Naushad /usr/local/lib/node_modules/cordova

export PATH=$PATH:/users/Naushad/android-sdks/tools

and then update your android if it is not updated to latest version :)
hope this will help some one.

No comments:

Post a Comment