You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

首次搭建React Native遭遇「Android SDK未找到」问题求助

Fixing "SDK location not found" Error in React Native Android Build

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.properties file
    Make sure the path in your project’s local.properties is correctly formatted. On Windows, it should look like this (replace YourUsername with your actual Windows username):

    sdk.dir=C\:\\Users\\YourUsername\\AppData\\Local\\Android\\Sdk
    

    Or you can use forward slashes to avoid escaping issues:

    sdk.dir=C:/Users/YourUsername/AppData/Local/Android/Sdk
    

    Common 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 with local.properties, React Native sometimes relies on system environment variables. Here’s how to set it up on Windows:

    1. Open System Properties (right-click This PC > Properties > Advanced system settings)
    2. Go to the "Environment Variables" section
    3. Under "System variables", click "New" and add:
      • Variable name: ANDROID_HOME
      • Variable value: C:\Users\YourUsername\AppData\Local\Android\Sdk
    4. Edit the Path variable and add these two entries:
      • %ANDROID_HOME%\platform-tools
      • %ANDROID_HOME%\tools
    5. Restart your terminal—environment changes won’t take effect until you do this.
  • Confirm the SDK is actually installed in that path
    Navigate to C:\Users\YourUsername\AppData\Local\Android\Sdk in File Explorer. You should see folders like platforms, 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.properties file
    If you’re using Android Studio, open your React Native project’s android folder in AS. Go to File > Project Structure > SDK Location and make sure the path matches your actual SDK directory. Android Studio will automatically generate/update the local.properties file 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 try npx react-native run-android again.

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:39:39