无法在 genymotion 中执行离子应用程序
Can't execute ionic application in genymotion
我尝试在 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
您可能没有所需的环境或OS到运行这个项目
我不清楚的是如何告诉 Cordova 使用 Genymotion 而不是默认的 Android 模拟器...
供参考,我是这样安装ionic和cordava的:
$ sudo npm install ionic -g
$ sudo npm install cordova -g
我正在研究 Linux Mint 17 Qiana / Cinnamon 64 位。
非常感谢您的帮助!
蒂埃里
从日志来看,这似乎不是 emulator/Genymotion 的问题,而是未安装 Android SDK 的问题。因为涉及的许可证 you typically need to install the Android SDK yourself.
这解释了错误消息:
- 首先查找SDK的安装位置,由
ANDROID_HOME
表示。它出错,因为它最初未设置。
- 设置后,找不到正确的 SDK(android-22、平台工具、工具),因为它们尚未安装。
我尝试在 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
您可能没有所需的环境或OS到运行这个项目
我不清楚的是如何告诉 Cordova 使用 Genymotion 而不是默认的 Android 模拟器...
供参考,我是这样安装ionic和cordava的:
$ sudo npm install ionic -g
$ sudo npm install cordova -g
我正在研究 Linux Mint 17 Qiana / Cinnamon 64 位。
非常感谢您的帮助! 蒂埃里
从日志来看,这似乎不是 emulator/Genymotion 的问题,而是未安装 Android SDK 的问题。因为涉及的许可证 you typically need to install the Android SDK yourself.
这解释了错误消息:
- 首先查找SDK的安装位置,由
ANDROID_HOME
表示。它出错,因为它最初未设置。 - 设置后,找不到正确的 SDK(android-22、平台工具、工具),因为它们尚未安装。