Error: Failed to find 'ANDROID_HOME' envir

2019-08-14 04:43发布

问题:

When i am running ionic app i am getting android home setting error. Here is my full commands and their output

sudo ionic run android

Running command: /home/manish/do_practice/ionic/hooks/after_prepare/010_add_platform_class.js /home/manish/do_practice/ionic
add to body class: platform-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.

Here is my ~/.bashrc file entry

export ANDROID_HOME=/home/manish/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

here is echo commands

echo $ANDROID_HOME
/home/manish/Android/Sdk
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/manish/Android/Sdk/tools:/home/manish/Android/Sdk/platform-tools

回答1:

Please reload your bashrc by using this command:

source ~/.bashrc


回答2:

"build-tools" directory is missing in your PATH. Remove both "export" lines from your .bashrc file and copy this:

export PATH=$PATH:/home/manish/Android/Sdk/platform-tools:/home/manish/Android/Sdk/tools:/home/manish/Android/Sdk/build-tools


回答3:

try to set tools as well, try following code ,edit this android sdk path to yours,

export ANDROID_HOME=/Users/Mac/Desktop/mac/android-sdk-macosx
PATH=$PATH:$ANDRIOD_HOME/tools
PATH=$PATH:$ANDRIOD_HOME/platform-tools