一尘不染

Ionic Android构建错误-无法找到'ANDROID_HOME'环境变量

linux

我正在尝试为Linux中的离子构建android,但它向我显示了这样的错误

     [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: /home/kumar/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/kumar/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.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)

我已经在我的bashrc文件中添加了它

export ANT_HOME="/usr/bin/ant"
export PATH="$PATH:$ANT_HOME/bin"
export HOME="/home/kumar"
export ANDROID_HOME="$HOME/android-sdk-linux/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/android-sdk-linux/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"

我想我已经给出了路径,但是我不知道为什么它向我显示此错误..请帮助…。


阅读 385

收藏
2020-06-07

共1个答案

一尘不染

Android Home应该是SDK的根文件夹。

export ANDROID_HOME="$HOME/android-sdk-linux"

编辑 :打开终端并键入这些命令。(是的,在ternimal上,不在bashrc文件中)

export ANDROID_HOME=~/android-sdk-macosx
PATH=$PATH:$ANDROID_HOME/tools
PATH=$PATH:$ANDROID_HOME/platform-tools

然后在同一终端中键入android。如果已配置,您将能够从此终端使用构建命令。(这是一个临时解决方案)

2020-06-07