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

1

4 Answers 4

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

1

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

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.