问题描述
我要在linux上安装cordova。当我想要构建Android平台时,ANDROID_HOME未设置,android命令不在您的PATH中。
我做了什么;
1。安装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
9。 sudo apt-get install openjdk-7-jre
10. sudo apt-get install openjdk-7-jdk
11. sudo apt-get install lib32stdc ++ 6
12.下载android sdk并解压缩/ home / sakarya / android-sdk-linux
13.打开sdk管理器并安装api 8,10,19,22和22 MNC及所有额外的
14. sudo nano〜/ .bashrc或sudo nano / root / bashrc或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创建你好 - 没有错误
cd hello
sudo cordova插件添加cordova插件网络信息 - 没有错误
sudo cordova平台添加android - 没有错误
sudo cordova build android - error
17. android命令工作。它打开sdk管理器。
原因是什么?
感谢。
原因是您导出变量并在用户中设置路径,然后使用sudo运行cordova。 p>
sudo不会像常规命令一样运行。 (有关更多信息,请参阅您的linux发行版的sudo doc)
好消息是,使用cordova cli时不需要sudo。
所以yust运行 cordova build android
,你可能有很好的惊喜。 (希望你不会有访问错误,因为你创建的项目使用sudo ...在这种情况下,重新启动从 cordova create ...
without sudo)
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.
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 android
and 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)
这篇关于在构建cordova项目时采取ANDROID_HOME PATH错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!