我尝试在Genymotion Android模拟器中执行使用Ionic实现的应用程序。
要创建我的应用程序,我执行了以下操作:
$ ionic start myApp blank
$ ionic platform android
$ ionic run android
请注意,我在启动虚拟终端后执行了最后一个命令(例如Sony Xperia Z)。
我有以下错误:
Running command: /(...)/myApp/hooks/after_prepare/010_add_platform_class.js /(...)/myApp
add to body class: platform-android
Running command: /(...)/myApp/platforms/android/cordova/build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /(...)/myApp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /(...)/myApp/platforms/android/cordova/build: Command failed with exit code 2
我不明白为什么我需要设置ANDROID_HOME
,因为它不是我想要使用的东西......
我安装了Android SDK并设置了ANDROID_HOME环境变量:
export ANDROID_HOME=/home/(...)/android-sdk-linux/
然后我出现以下错误:
$ ionic run android
Running command: /(...)/myApp/hooks/after_prepare/010_add_platform_class.js /(...)/myApp
add to body class: platform-android
Running command: /(...)/myApp/platforms/android/cordova/run
ERROR: Error: Please install Android target: "android-22".
Hint: Open the SDK manager by running: /home/(...)/android-sdk-linux/tools/android
You will require:
1. "SDK Platform" for android-22
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
ERROR running one or more of the platforms: Error: /(...)/myApp/platforms/android/cordova/run: Command failed with exit code 2
您可能没有运行此项目所需的环境或操作系统
我不清楚如何告诉Cordova使用Genymotion而不是默认的Android模拟器......
有关信息,我安装了离子和cordava:
$ sudo npm install ionic -g
$ sudo npm install cordova -g
我正在使用Linux Mint 17 Qiana / Cinnamon 64位。
非常感谢您的帮助! 亨利
答案 0 :(得分:2)
从日志中看,它看起来不像是模拟器/ Genymotion的问题,但是没有安装Android SDK的问题。由于涉及许可证you typically need to install the Android SDK yourself。
这解释了错误消息:
ANDROID_HOME
表示。它错误,因为它最初未设置。