2

I am using Ubuntu 14.04 LTS 64 bit, I have an ionic project and i have already Android installed, but when trying to emulate or run as Android i get these errors

Running command: /home/fathi/ionic/favorlinks/hooks/after_prepare/010_add_platform_class.js /home/fathi/ionic/favorlinks 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.

I have tried to modify ~/.bashrc file by adding this

export ANDROID_HOME=/home/fathi/Android/Sdk

But, i still getting the same errors

jemlifathi
  • 1,482
  • 5
  • 22
  • 32
  • try this : http://stackoverflow.com/questions/26356359/error-android-home-is-not-set-and-android-command-not-in-your-path-you-must-ful – Prashant Ghimire May 19 '16 at 23:32

2 Answers2

0

You are not including the ANDROID_HOME in PATH. Add the following code snippet in your ~/.bashrc.

export ANDROID_HOME=/home/fathi/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Note: Make sure to source the ~/.bashrc or open a new terminal.

RaviTezu
  • 3,047
  • 19
  • 26
  • I still getting the same error: Running command: /home/fathi/ionic/favorlinks/hooks/after_prepare/010_add_platform_class.js /home/fathi/ionic/favorlinks 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. – jemlifathi May 21 '16 at 18:34
  • What are the outputs of `echo $ANDROID_HOME` and `echo $PATH` ? – RaviTezu May 21 '16 at 18:50
  • echo $ANDROID_HOME /home/fathi/Android/Sdk echo $PATH /usr/local/heroku/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/fathi/Android/Sdk/tools:/home/fathi/Android/Sdk/platform-tools – jemlifathi May 21 '16 at 19:25
  • when i type android, it opens the Android SDK Manager – jemlifathi May 21 '16 at 19:26
0

After trying and installing many things, I fixed it by typing this command

sudo visudo

and then adding this line

Defaults    env_keep +="ANDROID_HOME"

at the end of the file.

jemlifathi
  • 1,482
  • 5
  • 22
  • 32