If your React Native Android build fails with this error, Gradle can’t find your Android SDK:
SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at 'YourApp/android/local.properties'.The fix takes two minutes. You can either tell this one project where the SDK is (Fix 1), or tell your whole computer (Fix 2). Fix 2 is better long-term, because every new project will just work.
Step 1: Find your Android SDK path
Open Android Studio and go to Settings (on macOS: Android Studio → Settings) → Languages & Frameworks → Android SDK. Copy the path shown in Android SDK Location. The default locations are:
- Windows:
C:\Users\YOUR_NAME\AppData\Local\Android\Sdk - macOS:
/Users/YOUR_NAME/Library/Android/sdk - Linux:
/home/YOUR_NAME/Android/Sdk
Fix 1: Create android/local.properties
Inside your project’s android folder, create a file called local.properties and add the sdk.dir line for your system. On Windows, every backslash must be doubled, and the colon after the drive letter is escaped:
# Windows
sdk.dir=C\:\\Users\\YOUR_NAME\\AppData\\Local\\Android\\Sdk
# macOS
sdk.dir=/Users/YOUR_NAME/Library/Android/sdk
# Linux
sdk.dir=/home/YOUR_NAME/Android/SdkDon’t commit this file to Git. The path is different on every computer, and the React Native template already lists local.properties in .gitignore.
Fix 2 (recommended): Set ANDROID_HOME for your whole system
macOS and Linux
Add these lines to ~/.zshrc (or ~/.bashrc on Linux), then open a new terminal:
export ANDROID_HOME=$HOME/Library/Android/sdk # Linux: $HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-toolsWindows
- Search Windows for Edit the system environment variables and click Environment Variables.
- Under User variables, click New. Name:
ANDROID_HOME, Value: your SDK path. - Select the Path variable, click Edit, and add
%ANDROID_HOME%\platform-tools. - Close and reopen your terminal and VS Code so they pick up the change.
Check that it worked
# Should print the SDK path
echo $ANDROID_HOME # Windows PowerShell: echo $env:ANDROID_HOME
# Should print a version number
adb --version
# Checks your whole React Native setup
npx react-native doctorThen rebuild with npx react-native run-android.
FAQ
I set ANDROID_HOME but still get the error. Why?
Your terminal or editor was opened before you set it. Restart them. If it still fails, add local.properties too (Fix 1); it takes priority for that project.
Should I use ANDROID_HOME or ANDROID_SDK_ROOT?
Use ANDROID_HOME. ANDROID_SDK_ROOT is deprecated.
The SDK folder doesn’t exist. What now?
Open Android Studio and finish the setup wizard. It downloads the SDK. Then install the Android SDK platform your React Native version needs from the SDK Manager.





