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

Ubuntu18.04下Flutter项目运行提示llvm-rs-cc缺失,flutter doctor未检测到问题

Fixing "llvm-rs-cc is missing" Error in Flutter on Ubuntu 18.04

Hey there! Let's work through this frustrating llvm-rs-cc is missing issue you're hitting. It's odd that flutter doctor gives you a clean bill of health but your Flutter project won't run—especially since your Kotlin projects work fine. The root cause here is almost always a mismatch between Flutter's expected NDK components and what's installed/configured on your system. Here are step-by-step fixes to get you up and running:

1. Install a Compatible NDK Version

llvm-rs-cc is part of the Android NDK, but newer NDK versions have renamed or removed this tool (it's replaced by clang in later releases). Flutter often relies on older NDK releases for compatibility:

  • Open Android Studio, go to Settings > Appearance & Behavior > System Settings > Android SDK
  • Switch to the SDK Tools tab, check the box for "Show Package Details"
  • Expand NDK (Side by side) and look for version 21.4.7075529 (this is a stable version that includes llvm-rs-cc)
  • If it's not installed, check the box next to it and click Apply to install

2. Point Flutter to the Correct NDK Path

Even if you install the right NDK, Flutter might not be picking it up automatically. Let's set it explicitly:

  • Open your Flutter project's android/local.properties file
  • Add this line (replace the path with your actual NDK installation path—Ubuntu's default is usually ~/Android/Sdk/ndk/21.4.7075529):
    ndk.dir=/home/your-username/Android/Sdk/ndk/21.4.7075529
    
  • Save the file, then run these commands in your project root:
    flutter clean
    flutter run
    

3. Verify Environment Variables

Sometimes Flutter can't find the NDK because your system environment variables aren't set correctly:

  • Open your shell config file (either ~/.bashrc or ~/.zshrc, depending on which shell you use)
  • Add or update these lines:
    export ANDROID_HOME=~/Android/Sdk
    export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/21.4.7075529
    export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_NDK_HOME
    
  • Save the file, then run source ~/.bashrc (or source ~/.zshrc) to apply the changes. Restart your terminal and try running your Flutter project again.

4. Match Build-Tools Version to NDK

Ensure your Android Build-Tools version is compatible with the NDK you installed:

  • Back in Android Studio's SDK Tools tab, expand Android SDK Build-Tools
  • Install version 30.0.3 (it pairs well with NDK 21.x)
  • After installation, run flutter clean once more and rebuild your project

Why does this work when Kotlin projects run fine?

Native Android projects often use different compilation paths that don't depend on llvm-rs-cc directly. Flutter's build pipeline, however, relies on this tool for certain native code compilation steps—especially when working with plugins that include C/C++ code. That's why you see the error only in Flutter projects.

内容的提问来源于stack exchange,提问作者Yogi W

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 07:27:01