1

I am having trouble setting the Android_Home variable on my MacOS. I have the MacBook Pro 2016 edition. Can't seem to find .profile. I tried to create it but looks like it didn't take. Any thoughts?

Thanks. -Nathan

  • 2
    Possible duplicate of [Setting ANDROID\_HOME enviromental variable on Mac OS X](http://stackoverflow.com/questions/19986214/setting-android-home-enviromental-variable-on-mac-os-x) – lwinkyawmyat Apr 29 '17 at 07:12

4 Answers4

4

The file is called .bash_profile and can be found in your home directory (/Users/<username>)

To add your ANDROID_HOME environment variable there, you would need to add the following line to your .bash_profile

export ANDROID_HOME=/path/to/android/sdk

To apply the changes, restart your terminal. Confirm that the changes have been applied by typing the following in your terminal:

echo $ANDROID_HOME

Your output should be /path/to/android/sdk as entered above.

Shams Shafiq
  • 3,884
  • 3
  • 16
  • 21
1

These line should be add to your Shell Initialization Files

export ANDROID_HOME=/Users/{YourUserName}/Library/Android/sdk
export ANDROID_NDK=$ANDROID_HOME/ndk-bundle
  • If you are using bash (by default), you should add these lines to your ~.bash_profile or ~.bashrc
  • If you are using zsh, you should add these lines to your ~/.zshrc
evan wang
  • 32
  • 3
0

Old school way to check if .bash_profile file exists following could be done:

  1. Go to Finder>Go>COMPUTER>Mac HD>Users, THEN click on your user account.

enter image description here

  1. Now hold down ⌘ + ⇧ + ., this will now display hidden files and folders. It will look something like this:

enter image description here

In case the ⌘ + ⇧ + . does not work, please look up the keyboard shortcut relevant for your Mac Operating system name.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
zennni
  • 1,397
  • 15
  • 12
0

If you are setting up the ANDROID_HOME environment variable on macOS Catalina, .bash_profile is no longer Apple's default shell, and it won't persist your path variables. Use .zprofile instead and follow the environment setup instructions in react-native documentation or others. .bash_profile will keep creating new file which won't make the path permanent or persist on closing the terminal on your system path.

To create a new path just do this in macOS Big Sur:

  1. sudo touch ~/.zshrc
  2. sudo nano ~/.zshrc
  3. export all the path
  4. ctrl + x and save
  5. source ~/.zshrc
  6. Check with echo $PATH
Dharman
  • 30,962
  • 25
  • 85
  • 135
Bhavya Koshiya
  • 1,262
  • 2
  • 8
  • 22