user7939208
user7939208

Reputation:

Set up the ANDROID_HOME environment variable on MacOS

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

Upvotes: 1

Views: 5981

Answers (4)

Bhavya Koshiya
Bhavya Koshiya

Reputation: 1806

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

Upvotes: 1

zennni
zennni

Reputation: 1717

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.

Upvotes: 0

evan wang
evan wang

Reputation: 32

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

Upvotes: 1

Shams Shafiq
Shams Shafiq

Reputation: 4008

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.

Upvotes: 4

Related Questions