在终端中运行以下命令:
$ cd ~/Library/Android/sdk/tools/bin $ ./sdkmanager --list
如果出现错误,可以在终端中运行以下命令来安装Android Sdk:
$ brew update $ brew install android-sdk
$ echo $ANDROID_HOME
如果没有输出,或者输出结果不是Android Sdk所在的路径,请运行以下命令:
$ export ANDROID_HOME=$HOME/Library/Android/sdk
$ sdkmanager --update
$ sdkmanager "platforms;android-29" "build-tools;29.0.2"
$ export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
$ react-native run-android
示例代码:
export ANDROID_HOME=$HOME/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
cd /path/to/project react-native run-android