ANDROID_HOME issue in zhs terminal for macOS Catalina

Imdad Hussain
3 min readNov 25, 2020

Macs will now use zsh as the default login shell and interactive shell across the operating system. All newly created user accounts in macOS Catalina will use zsh by default.

This article will answer following answers:

  1. You are unable to find Android Home environment variables for bash or zhs terminal
  2. You are not able to generate React-Native app build with terminal

To check if you have Android home environment variable run this command

echo $ANDROID_HOME

There are two steps to fix this issue,

  1. Switch to old bash terminal
  2. Stay with new zsh terminal and resolve Android Home environment variable issue

1. Switch to old bash terminal

Click on the System Preferences icon or hit Cmd + Spacebar to open Spotlight and type System Preferences and open it.

Now, select Users & Groups.

At the bottom left you will see the lock. Click it and enter your password to unlock it.

Press the Ctrl key and click on the Current User profile this will open the Advanced Options… Click it.

Now, pick your Login shell from the dropdown menu and click the OK button.

restart terminal and you are back to your old shell terminal. That’s it

2. Stay with new zsh terminal and resolve Android Home environment variable issue

Where the Android-SDK is installed depends on how you installed it.

  1. If you downloaded the SDK through their website and then dragged/dropped the Application to your Applications folder, it’s most likely here:/Applications/ADT/sdk (as it is in your case).
  2. If you installed the SDK using Homebrew (brew cask install android-sdk), then it's located here:/usr/local/Caskroom/android-sdk/{YOUR_SDK_VERSION_NUMBER}
  3. If the SDK was installed automatically as part of Android Studio then it’s located here:/Users/{YOUR_USER_NAME}/Library/Android/sdk

Once you know the location, open a terminal window and enter the following (changing out the path to the SDK to be however you installed it):

export ANDROID_HOME={YOUR_PATH}

you_path will look like this: /Users/username/Library/Android/sdk
Once you have this set, you need to add this to the PATH environment variable:

export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Lastly apply these changes by re-sourcing .bash_profile:

source ~/.bash_profile

Type — echo $ANDROID_HOME to check if the home is set.

echo $ANDROID_HOME

If you are facing adb device not connect issue, or you are not able to run your React-Native project on connected Android device. You have to follow following steps too.

Is adb installed? To check, run the following command in Terminal:

~/Library/Android/sdk/platform-tools/adb

If that prints output, skip these following install steps and go straight to the final Terminal command I list:

  1. Launch Android Studio
  2. Launch SDK Manager via Tools -> Android -> SDK Manager
  3. Check Android SDK Platform-Tools

Run the following command on your Mac and restart your Terminal session:

echo export "PATH=~/Library/Android/sdk/platform-tools:$PATH" >> ~/.bash_profile

Note: If you’ve switched to zsh, the above command should use .zshenv rather than .bash_profile like this

echo export "PATH=~/Library/Android/sdk/platform-tools:$PATH" >> ~/.zshenv

That’s it. You are good to go with your new zhs terminal.

--

--

Imdad Hussain
Imdad Hussain

Written by Imdad Hussain

Senior React & React Native Developer @thoughtworks | JavaScript & TypeScript ❤️

No responses yet