Reputation: 3771
The issue looks very familiar with this Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
But I am not able to fix it. When I run
% sudo cordova build android
I am getting the following error
Running command: /home/thabung/mobile/hello/platforms/android/cordova/build
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/thabung/mobile/hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/thabung/mobile/hello/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131: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)
Few things I am observing
% echo $ANDROID_HOME
returns me
~/mobile/android-sdk-linux
which is perfect location & android command also works fine. Please help.. I am using cordova 4.3.0
Upvotes: 2
Views: 277
Reputation: 13967
This ...
sudo cordova build android
runs in the environment of root whereas this ...
echo $ANDROID_HOME
was not executed as root. Check what echo $ANDROID_HOME
returns as root - or (strongly recommended) - run Cordova as another user than root.
p.s.: I'm running Cordova 4.0.0 on Ubuntu 14.04 without sudo
.
Upvotes: 2