【问题标题】:Can't execute ionic application in genymotion无法在genymotion中执行离子应用程序
【发布时间】:2016-03-01 16:32:38
【问题描述】:

我尝试在 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 模拟器...

有关信息,我这样安装了 ionic 和 cordava:

$ sudo npm install ionic -g
$ sudo npm install cordova -g

我正在开发 Linux Mint 17 Qiana / Cinnamon 64 位。

非常感谢您的帮助! 蒂埃里

【问题讨论】:

  • 也许this question on the forum 会有所帮助。
  • 感谢您的 cmets!我更新了我的问题。事实上,它比仅仅设置一个环境变量更广泛。它是关于使用 Genymotion 而不是默认的 Android 模拟器的方式...
  • 完成 Daniel Lew 所说的所有操作后,您只需启动 genymotion 模拟器并执行 ionic run android 即可在 genymotion 中启动您的 ionic 应用程序。

标签: android ionic genymotion


【解决方案1】:

从日志来看,这似乎不是模拟器/Genymotion 的问题,而是没有安装 Android SDK 的问题。因为涉及you typically need to install the Android SDK yourself的许可证。

这解释了错误消息:

  1. 首先查找SDK的安装位置,由ANDROID_HOME指示。由于最初未设置,因此会出错。
  2. 设置后,由于未安装,因此无法找到正确的 SDK(android-22、平台工具、工具)。

【讨论】:

  • 非常感谢您的帮助!我不清楚我们是否还需要 android sdk 才能使用 genymotion...我可以在模拟器中查看我的应用程序 ;-)
猜你喜欢
  • 2017-12-12
  • 1970-01-01
  • 2018-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-05
  • 1970-01-01
  • 2018-12-10
相关资源
最近更新 更多