16

I am MAC OS X Yosemite I have done all the export tutorial to set the android_home but non of it working for me

CMP
  • 435
  • 3
  • 8
  • 22

6 Answers6

17

Making sure ANDROID_HOME is exported and adding the SDK tool directories to PATH should be more than enough to get you going.


Using the terminal

# First, we make sure we have a newline at the end of the .bash_profile
echo >> /Users/abdi/.bash_profile

# We set the ANDROID_HOME value in the .bash_profile
echo "export ANDROID_HOME=/Users/abdi/adt/sdk" >> /Users/abdi/.bash_profile

# We alter the PATH value a bit as well
echo "export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" >> /Users/abdi/.bash_profile

# We then tell the terminal to update all the things
. /Users/abdi/.bash_profile

Using a GUI (mostly)

You can also open the .bash_profile file in TextEdit using the open -e /Users/abdi/.bash_profile command. If you get some errors about missing files, try running touch /Users/abdi/.bash_profile and retry the open command. In the file that opens, add the following lines at the end.

export ANDROID_HOME=/Users/abdi/adt/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Running . /Users/abdi/.bash_profile as in the terminal version after that should get you fully set up.

Valter Jansons
  • 3,904
  • 1
  • 22
  • 25
  • 1
    the varaibles seem to be set but my command line still returning same error – CMP Nov 02 '14 at 16:36
  • Okay, after confirming the .bash_profile file has the two lines at the end, try closing and re-opening the terminal window so that it updates all the things for sure. If that doesn't work, please provide the output of `echo $PATH` and `ls /Users/abdi/adt/sdk`. – Valter Jansons Nov 02 '14 at 16:39
  • So this what am experiencing now ANDROID_HOME is for one terminal but not the others when I want to run for example sudo commands will send me error of android_home not seet – CMP Nov 03 '14 at 16:25
  • I would suggest trying to manually run the `export` commands by themselves in the terminals that are not working if it is not feasible to restart them. Not 100% sure, but I believe `sudo` messes with env vars as well. Why are you using `sudo` anyway? – Valter Jansons Nov 03 '14 at 16:30
7

First need to set the ANDROID_HOME directory look into your android-sdk-linux(mac) directory and look for 'android' executable file, generally it will exists under 'tools' directory

so edit your .bashrc from home folder

and add this line down there

export ANDROID_HOME=~/android-sdk-linux
PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Once done, exit your console and run your command again

You could expect an error saying " Please install Android target "android-19" " if it is not set yet.

you may fix that running "android" command and selecting "Android 4.4.2 API 19" to install.

And afterwards, don't forget to give ample permission to directory where the application resides.

Code Tree
  • 2,160
  • 4
  • 26
  • 39
3

I had the same problem. Luckily it is easily fixable. Just follow the next few steps (Command-line from terminal).

  1. Open the bash_profile file using command line arguments with -

    vi ~/.bash_profile

OR

It is possible to open bash_profile in TextEdit and make changes there. Use the following command to do this -

open -a "TextEdit" .bash_profile

  1. Check if ANDROID_HOME has been set in this file. If it has been already set, delete it (probably wrong). Also check if PATH in this file has any reference to tools or platform-tools (of the android sdk). You'd be better off deleting these before you start typing the following commands.

  2. Set ANDROID_HOME correctly using the following command export ANDROID_HOME=/Users/adarsh/android-sdk-macosx

^this is my command because I installed it in that location. Please replace "adarsh" with your username and "android-sdk-manager" with the name of your android sdk folder that you downloaded. Do not copy-paste this command.

For example, if your username is "John" and you the android sdk folder you downloaded and installed is in "Downloads" and you changed your folder name to "sdk", then your command would be -

export ANDROID_HOME=/Users/John/Downloads/sdk

  1. Set PATH with the following command

    export PATH=$ANDROID_HOME/tools:$PATH

  2. Refresh your bash_profile to set all the changes we just made by typing the command

    source ~/.bash_profile

You should be good to go now and begin developing with ionic!Hope this helps. Cheers.

mutp
  • 2,301
  • 1
  • 17
  • 13
2

One source of this problem comes from sudo. If you're sure you've set $ANDROID_HOME correctly then try the following:

sudo visudo

then add

Defaults    env_keep += "ANDROID_HOME"
0

Make sure the env variable you exported is ANDROID_HOME and not android_home (case sensitive).

After you export, test it by typing

> echo $ANDROID_HOME

The result should point to the dir where you installed the SDK.

Last but not least edit your /etc/paths to add dirs $ANDROID_HOME/platform-tools or /Users/abdi/adt/sdk/platform-tools and $ANDROID_HOME/tools or /Users/abdi/adt/sdk/tools to the list. Save file. You might need to edit this file as admin if need be. Close terminal and then Open new terminal. Then type

> echo $PATH

to check if the path is updated.

And then voila, when you type

> which android

you should see the correct path to the binary returned which in your case is /Users/abdi/adt/sdk/tools/android. you should be all set now.

VJ Vélan Solutions
  • 6,434
  • 5
  • 49
  • 63
  • this returns -->/Users/abdi/adt/sdk where my sdk is – CMP Nov 02 '14 at 15:55
  • So i have followwed these steps which android returns my android path and ANDROID_HOME returns my android path but terminal to run my commands it still returns same error – CMP Nov 02 '14 at 16:10
  • Modifying /etc/paths seems fairly invasive. We can't even guarantee other users will have read rights to the directories referenced. – Valter Jansons Nov 02 '14 at 16:14
  • > but terminal to run my commands it still returns same error --> may be you need to close that terminal and launch a new one. – VJ Vélan Solutions Nov 02 '14 at 16:37
0

None of the solutions here solved my problem completely. My Node version was little bit old and ionic was giving a warning to upgrade node. After upgrading Node, I had to delete the project and again create the project, then perform all the steps. Hope this helps somebody.

Swamy
  • 771
  • 1
  • 8
  • 24