0

I'm tring to install cordova on linux. When I want build android platform taking ANDROID_HOME is not set and "android" command not in your PATH.

What I did;

1. installed lubuntu 2. sudo apt-get update 3. sudo apt-get upgrade 4. sudo apt-get install git 5. sudo apt-get install nodejs 6. sudo apt-get install npm 7. sudo ln -s /usr/bin/nodejs /usr/bin/node 8. sudo apt-get install ant 9. sudo apt-get install openjdk-7-jre 10. sudo apt-get install openjdk-7-jdk 11. sudo apt-get install lib32stdc++6 12. downloaded android sdk and unzipped /home/sakarya/android-sdk-linux 13. opened sdk manager and installed api 8, 10, 19, 22 and 22 MNC with all extras 14. sudo nano ~/.bashrc or sudo nano /root/bashrc or sudo nano ~/.profile export ANDROID_HOME="~/android-sdk-linux" export PATH=${PATH}:~/android-sdk-linux/tools export PATH=${PATH}:~/android-sdk-linux/platform-tools --or-- export ANDROID_HOME = "~/android-sdk-linux" export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" 15. sudo npm install -g cordova 16. dir: /home/sakarya sudo cordova create hello - no error cd hello sudo cordova plugin add cordova-plugin-network-information - no error sudo cordova platform add android - no error sudo cordova build android - error 17. android command works. it opens sdk manager. 

What the reason can be?

Thanks.

1 Answer 1

2

The reason is that you export variables and set path in your user and then use sudo to run cordova.

sudo does not run in the same env as regular commands. (see the sudo doc of your linux distribution for more info)

the good news is that you don't need sudo when using the cordova cli.

So yust run cordova build androidand you may have good surprises. (hope you won't have access errors because you created the project using sudo... in that case, restart from cordova create... without sudo)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.