我想构建一个离子应用程序,但是当我在终端上运行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存在的正确路径,但为什么存在这样的错误?我已经搜索到足以解决这个问题,但它仍然会给出同样的错误。
请帮忙。
答案 0 :(得分:1)
错误是自我解释:
[Error: 'ANDROID_HOME' environment variable is set to non-existent path: /Android/Sdk
这意味着/Android/Sdk
路径不存在,因此您应修复$ANDROID_HOME
环境变量以指向真实路径。
要检查此路径是否存在,请从终端ls /Android/Sdk
运行。您应该收到同样的错误。
请参阅this question以了解如何永久设置此变量。
答案 1 :(得分:1)
尝试更改“我的电脑” - >“属性” - >“高级系统”属性 - >更改“环境变量”。
我认为这可能有效
答案 2 :(得分:0)
我将环境变量添加到我的系统变量中,关闭ms窗口并打开新窗口,问题已经消失