Reputation: 13
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
Reputation: 1374
Instruction 1: After adding your ANDROID_HOME, make sure you do the below:
Restart your System or run "source ~/.bash_profile"
Remove Android platform from your project "ionic cordova platform rm android" or "ionic platform rm android"
Add Android platform "ionic cordova platform add android"
Then "ionic cordova run android" or "ionic run android"
Instruction 2: To set your ANDROID_HOME and JAVA_HOME, follow the below steps:
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1 export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Hope this helps.
Upvotes: 1