我正在尝试使用phonegap create创建一个用于创建phonegap项目的android版本。
我已经为ANDROID_HOME和PATH等设置了env变量,但它仍然无法正常工作。
我错过了什么吗?
MacBook-Pro-de-Guilherme-GM:ssgt guilhermegm$ echo $ANDROID_HOME
/usr/local/Cellar/android-sdk/23.0.2
MacBook-Pro-de-Guilherme-GM:ssgt guilhermegm$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/Cellar/android-sdk/23.0.2/platform-tools:/usr/local/Cellar/android-sdk/23.0.2/tools
MacBook-Pro-de-Guilherme-GM:ssgt guilhermegm$ sudo cordova build android
cp: no such file or directory: /Users/guilhermegm/Projects/ssgt/frontend/ssgt/icon.png
cp: no such file or directory: /Users/guilhermegm/Projects/ssgt/frontend/ssgt/www/res/icon/ios/icon-72.png
cp: no such file or directory: /Users/guilhermegm/Projects/ssgt/frontend/ssgt/www/res/icon/ios/icon-72-2x.png
Running command: /Users/guilhermegm/Projects/ssgt/frontend/ssgt/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: /Users/guilhermegm/Projects/ssgt/frontend/ssgt/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:755:16)
at Process.ChildProcess._handle.onexit (child_process.js:822:5)
MacBook-Pro-de-Guilherme-GM:ssgt guilhermegm$
答案 0 :(得分:1)
我和你一样的问题,就像你使用什么操作系统一样? 在我将OS X更新到新版本之前,它可以完美运行。
在我的cordova项目中添加android平台时遇到了同样的问题, 当我在〜/ .bash_profile中注册环境变量时,就像这样
#Android
export PATH=${PATH}:/Users/donny/Documents/android/sdk/platform-tools:/Users/donny/Documents/android/sdk/tools
export ANDROID_HOME=/Users/donny/Documents/android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME:/platform-tools
然后我保存它,并执行我的新bash_profile
$ source ~/.bash_profile
然后我检查ANDROID_HOME是否已经注册
$ echo $ANDROID_HOME
$ /Users/donny/Documents/android/sdk
你可以看到它正确回归
但当我关闭终端并再次打开终端时,或在新标签页中打开终端并运行
$ echo $ANDROID_HOME
$
它返回空白 我认为这是我的OS X的问题,但我不确切地知道那个
谢谢,
答案 1 :(得分:0)
在.bash_profile
export PATH=${PATH}:/Applications/android-sdk/platform-tools
export PATH=${PATH}:/Applications/android-sdk/tools
答案 2 :(得分:0)
尝试检查ANDROID_HOME是否转到正确的子目录。由于您的平台工具位于" 23.0.2" (/usr/local/Cellar/android-sdk/23.0.2/platform-tools)将ANDROID_HOME设置为:/usr/local/Cellar/android-sdk/23.0.2