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

React Native Android项目运行报错:NDK缺失问题求助

Fixing NDK Missing Error in React Native Android Project

Hey there, let's tackle that NDK missing error you're facing with your React Native Android project! Even with your Android and Java system variables set up correctly, this is a super common hiccup—here's how to fix it step by step:

Step 1: Install the Correct NDK Version via Android Studio

Different React Native versions require specific NDK versions (for example, RN 0.70+ needs NDK 25.1.8937393—double-check your RN docs for the exact version you need):

  • Open Android Studio, go to Settings (Windows/Linux: File > Settings; Mac: Android Studio > Settings)
  • Navigate to Appearance & Behavior > System Settings > Android SDK
  • Switch to the SDK Tools tab, then check the Show Package Details box at the bottom-right
  • Find NDK (Side by side), expand it, and check the box next to your required NDK version
  • Click Apply to start the installation

Step 2: Point Your Project to the Installed NDK

Your project might not automatically detect the NDK even after installation—let's set it explicitly:

  • Go to your React Native project's root folder, open (or create if missing) the android/local.properties file
  • Add this line, replacing the path with your actual NDK installation path:
    # Windows example
    ndk.dir=C\:\\Users\\YourUsername\\AppData\\Local\\Android\\Sdk\\ndk\\25.1.8937393
    
    # Mac/Linux example
    ndk.dir=/Users/YourUsername/Library/Android/sdk/ndk/25.1.8937393
    
  • Make sure to escape backslashes on Windows, or use forward slashes instead

To avoid version mismatches later, hardcode the NDK version in your project's gradle config:

  • Open android/build.gradle and look for the ext block. Add or update the ndkVersion line:
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
        ndkVersion = "25.1.8937393" // Match the version you installed
    }
    
  • Click the Sync Now button in Android Studio to apply the changes

Step 4: Clean Cache and Re-run

Old cache can sometimes cause lingering issues, so let's wipe it and restart:

  • Run this command to reset React Native's cache:
    npx react-native start --reset-cache
    
  • Then re-launch your Android project:
    npx react-native run-android
    

Quick Bonus: Install NDK via Command Line

If you prefer using the terminal instead of Android Studio, you can use the sdkmanager tool (make sure it's in your system PATH):

sdkmanager --install "ndk;25.1.8937393"

内容的提问来源于stack exchange,提问作者Sathya Raj

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 06:43:16