【问题标题】:"Error: 'ANDROID_HOME' environment variable is set to non-existent path" on ubuntuubuntu 上的“错误:‘ANDROID_HOME’环境变量设置为不存在的路径”
【发布时间】:2015-09-03 05:26:26
【问题描述】:

我想构建一个 ionic 应用程序,但是当我在终端上运行 ionic build android 时出现以下错误,

Running command: /home/shamil/learn/Ionic/myApp/hooks/after_prepare/010_add_platform_class.js /home/shamil/learn/Ionic/myApp
add to body class: platform-android
Running command: /home/shamil/learn/Ionic/myApp/platforms/android/cordova/build 
[Error: 'ANDROID_HOME' environment variable is set to non-existent path: /Android/Sdk
Try update it manually to point to valid SDK directory.]
ERROR building one of the platforms: Error: /home/shamil/learn/Ionic/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: /home/shamil/learn/Ionic/myApp/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:139:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

我已经给出了sdk存在的正确路径,但是为什么会出现这样的错误呢?我已经搜索了足够的东西来解决这个问题,但它仍然给出了同样的错误。

请帮忙。

【问题讨论】:

标签: android cordova sdk ionic


【解决方案1】:

错误是自我解释的:

[Error: 'ANDROID_HOME' environment variable is set to non-existent path: /Android/Sdk

这意味着/Android/Sdk 路径不存在,因此您应该修复$ANDROID_HOME 环境变量以指向真实路径。

要检查此路径是否不存在,请从终端运行:ls /Android/Sdk。您应该会收到同样的错误。

请参阅this question 了解如何永久设置此变量。

【讨论】:

  • 我得到同样的错误,我的路径是正确的。事实上,我从资源管理器中复制了它。在 Windows 上,这是我设置的 ->“C:\Program Files (x86)\Android\android-sdk”。我仍然得到同样的错误。
  • @Sudeep Unnikrishnan - 我在寡妇中遇到了同样的问题。我做错的是用双引号设置路径,例如设置 ANDROID_HOME="C:\Program Files (x86)\Android\android-sdk" ... 相反,我不得不不使用双引号,它起作用了: set ANDROID_HOME=C:\Program Files (x86)\Android\android- sdk
  • 我得到non-existent path: /mnt/c/Android/LinuxSDK,当我运行ls /mnt/c/Android/LinuxSDK时,我得到build-tools licenses platforms platform-tools tools
【解决方案2】:

尝试从我的电脑->属性->高级系统属性->更改环境变量。

我认为这可能有效

【讨论】:

    【解决方案3】:

    我将环境变量添加到我的系统变量中,关闭 ms 窗口并打开新窗口,问题消失了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-23
      • 1970-01-01
      • 2017-09-27
      • 2018-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多