HARISH RATHOR
HARISH RATHOR

Reputation: 13

Ionic Build-Error: Error: Failed to find 'ANDROID_HOME' environment variable. Failed to find 'android' command in your 'PATH'

I am facing a problem whan I am running command: $ ionic build android The output is: 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.

My .bashrc file :

export ANDROID_HOME=/home/harishrathor/Desktop/IonicApp/android-sdk-linux/tools
export PATH=$PATH:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/tools/:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/platform-tools/:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/build-tools/23.0.1

Echo $path command:

$ echo $PATH 
/home/harishrathor/bin:/home/harishrathor/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/local/jdk1.8.0_74/bin:/home/harishrathor/.config/composer/vendor/bin:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/tools/:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/platform-tools/:/home/harishrathor/Desktop/IonicApp/android-sdk-linux/platform-tools/23.0.1

Echo $ANDROID_HOME is:

 $ echo $ANDROID_HOME 
/home/harishrathor/Desktop/IonicApp/android-sdk-linux

Above $PATH and $ANDROID_HOME outputs are from application directory.

From $HOME directory the output is:

$ echo $ANDROID_HOME 
/home/harishrathor/Desktop/IonicApp/android-sdk-linux/tools/android

And the android-sdk-linux is located in the given directory. But it is still showing this error. Someone, please help me.


Upvotes: 0

Views: 1033

Answers (1)

Victor Ejiogu
Victor Ejiogu

Reputation: 1374

Instruction 1: After adding your ANDROID_HOME, make sure you do the below:

  1. Restart your System or run "source ~/.bash_profile"

  2. Remove Android platform from your project "ionic cordova platform rm android" or "ionic platform rm android"

  3. Add Android platform "ionic cordova platform add android"

  4. Then "ionic cordova run android" or "ionic run android"

Instruction 2: To set your ANDROID_HOME and JAVA_HOME, follow the below steps:

  1. Run command "open ~/.bash_profile"
  2. Paste the below in the file that opens on your Text editor

export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1 export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

  1. Save - "Command S" or "Ctrl S"
  2. Then Follow the "Instruction 1:" above

Hope this helps.

Upvotes: 1

Related Questions