以下是我正在使用的技术的基本信息, mac osx yosemite在我的macbook pro上, iterm作为命令行工具 cordova 5.4.1
现在让我解释一下我的问题, 最初我在我的mac上安装了大约19或20的android sdk的旧cordova版本,我能够为默认的cordova应用程序构建android和ios构建。
之后我想尝试使用离子框架,为此我不知道为什么但是我必须升级我的npm,cordova等......我用下面的链接步骤 http://www.johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/
现在升级之后我能够安装离子CLI并且能够安装默认的离子应用程序但是现在当我尝试构建Android应用程序时,它给我下面的错误堆栈跟踪,我将最后列出错误日志。
我尝试安装最新的Android sdk版本24.0.1但仍然是错误相同。 因此,即使在所有需要最新的sdk版本之后,它仍然会给我一个错误,即根据错误日志我没有正确的sdk构建工具,
所以这是错误日志, 我跑的时候 cordova build android
Running command: /Users/myusername/Desktop/projects/demo8/platforms/android/cordova/build
ANDROID_HOME=/usr/local/opt/android-sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/myusername/Desktop/projects/demo8/platforms/android/gradlew cdvBuildDebug -b /Users/myusername/Desktop/projects/demo8/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* Where:
Script '/Users/myusername/Desktop/projects/demo8/platforms/android/CordovaLib/cordova.gradle' line: 64
* What went wrong:
A problem occurred evaluating root project 'android'.
> No installed build tools found. Please install the Android build tools version 19.1.0 or higher.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.235 secs
/Users/myusername/Desktop/projects/demo8/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/myusername/Desktop/projects/demo8/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/myusername/Desktop/projects/demo8/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/myusername/Desktop/projects/demo8/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/myusername/Desktop/projects/demo8/platforms/android/cordova/build: Command failed with exit code 1
我已经正确设置了路径,你可以看到它们,
export PATH=~/.composer/vendor/bin:$PATH
export PATH=/Applications/MAMP/bin/php/php5.6.6/bin:$PATH
export PATH=/Users/myusername/android-sdk-macosx/tools:$PATH
export PATH=/Users/myusername/android-sdk-macosx/platform-tools:$PATH
export PATH=~/npm-global/bin:$PATH
alias mphp='/Applications/MAMP/bin/php/php5.6.6/bin'
alias serve='php artisan serve'
alias art='php artisan'
source ~/.bashrc
那么,有没有任何帮助,以便我可以构建Android应用程序,
由于
答案 0 :(得分:1)
您是否编辑了路径的/ Users / myusername部分,或者忘记将其设为实际的用户名?
您可以这样做:
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
答案 1 :(得分:0)
最后我得到了答案,如下所示, 根据我使用http://johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/更新npm和节点,我在我的bash_profile中添加了.bashrc源,并且bashrc文件有错误的ANDROID_HOME路径,我改变了,现在一切正常。
感谢回答此问题的人。