首次搭建React Native遭遇「Android SDK未找到」问题求助
Hey there, I totally get how frustrating this is—first-time React Native setup can throw all sorts of curveballs, especially when you’ve followed the steps but still hit this wall. Let’s walk through some concrete fixes that usually resolve this issue:
Double-check your
local.propertiesfile
Make sure the path in your project’slocal.propertiesis correctly formatted. On Windows, it should look like this (replaceYourUsernamewith your actual Windows username):sdk.dir=C\:\\Users\\YourUsername\\AppData\\Local\\Android\\SdkOr you can use forward slashes to avoid escaping issues:
sdk.dir=C:/Users/YourUsername/AppData/Local/Android/SdkCommon mistakes here: typos in the username, missing a backslash/forward slash, or pointing to a folder that doesn’t actually contain the SDK.
Verify your ANDROID_HOME environment variable
Even withlocal.properties, React Native sometimes relies on system environment variables. Here’s how to set it up on Windows:- Open System Properties (right-click This PC > Properties > Advanced system settings)
- Go to the "Environment Variables" section
- Under "System variables", click "New" and add:
- Variable name:
ANDROID_HOME - Variable value:
C:\Users\YourUsername\AppData\Local\Android\Sdk
- Variable name:
- Edit the
Pathvariable and add these two entries:%ANDROID_HOME%\platform-tools%ANDROID_HOME%\tools
- Restart your terminal—environment changes won’t take effect until you do this.
Confirm the SDK is actually installed in that path
Navigate toC:\Users\YourUsername\AppData\Local\Android\Sdkin File Explorer. You should see folders likeplatforms,platform-tools,build-tools, etc. If these are missing, your SDK installation might have failed—try re-installing via Android Studio’s SDK Manager.Let Android Studio handle the
local.propertiesfile
If you’re using Android Studio, open your React Native project’sandroidfolder in AS. Go toFile > Project Structure > SDK Locationand make sure the path matches your actual SDK directory. Android Studio will automatically generate/update thelocal.propertiesfile correctly, which avoids manual formatting errors.Try running the build with administrator privileges
On rare occasions, permission issues can prevent the build process from accessing the SDK folder. Right-click your terminal (Command Prompt/PowerShell) and select "Run as administrator", then trynpx react-native run-androidagain.
If none of these work, share the exact content of your local.properties file and any additional details from the build log—this can help pinpoint the issue further!
内容的提问来源于stack exchange,提问作者Alexander Valtingojer

