ANDROID_HOME issue in zhs terminal for macOS Catalina
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:
- You are unable to find Android Home environment variables for bash or zhs terminal
- You are not able to generate React-Native app build with terminal
To check if you have Android home environment variable run this command
There are two steps to fix this issue,
- Switch to old bash terminal
- 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.
- 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).
- If you installed the SDK using Homebrew (
brew cask install android-sdk), then it's located here:
- If the SDK was installed automatically as part of Android Studio then it’s located here:
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):
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:
Lastly apply these changes by re-sourcing .bash_profile:
Type — echo $ANDROID_HOME to check if the home is set.
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:
If that prints output, skip these following install steps and go straight to the final Terminal command I list:
- Launch Android Studio
- Launch SDK Manager via Tools -> Android -> SDK Manager
- 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.