The React Native command line interface requires the ANDROID_HOME environment variable to be set up. You can configure it in a Terminal using the following command:
export ANDROID_HOME=~/Library/Android/sdk
To avoid doing this every time you open a new Terminal, create (or edit) ~/.bashrc using your favorite text editor and add the following lines:
1、 export ANDROID_HOME=~/Library/Android/sdk
2、 export PATH=${PATH}:${ANDROID_HOME}/tools 将本句改为:
export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
The second line will add the android tool to your path, which will come in handy in the next step.
Please make sure you export the correct path for ANDROID_HOME if you did not install the Android SDK using Android Studio. If you install the Android SDK using Homebrew, it will be located at /usr/local/opt/android-sdk.