Run react-native on android emulator
I had a similar problem, and after spending so much time and lots of searching about this issue the only trick worked for me:
- Please Install the Required SDKs as shown in this figure
Configure Required SDKs
- If You have already installed it, so you must have to update the following SDKs:
Android SDK Tool
(update it to latest version)Android SDK Platform-tools
(update it to latest version)Android SDK Build-tools
(update it to latest version)Android Support Repository
underExtra
folder (update it to latest version)
- You Must have at least Installed the Same version
Android API
as the installedAndroid SDK Build-tools
&Android SDK Platform-tools
version as shown in theConfigure Required SDKs
figure above.
Note: Local Maven repository for Support Libraries which is listed as the SDK requirement in the official docs of React-native is now named as Android Support Repository in the SDK Manager .
React Native (On Mac OS Big SUR)
i was stuck here. But updating the environment settings for Android studio did the trick.
nano ~/.zshrc
and paste
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
export JAVA_HOME=$(/usr/libexec/java_home)
control + o
to save
then enter
then control + x
to exit
then do
source ~/.zshrc
to compile
kill the runnig terminals and run
npx react-native run-android
On macOs I manage to fix this by adding:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
to ~/.zsh_profile file.
and than type to your terminal
source $HOME/.zsh_profile
The issue was caused by using iTerm2 shell so it's required to edit its own config instead of default $HOME/.bash_profile as described in the official documentation https://reactnative.dev/docs/environment-setup