tauri-apps/tauri · error
Android NDK invalid. Make sure the NDK_HOME environment vari
Error message
Android NDK invalid. Make sure the NDK_HOME environment variable has correct value.
What it means
ensure_ndk() found the NDK_HOME environment variable set, but its value is not an existing directory (is_dir() returned false). The CLI refuses to guess and aborts so you can correct the path — typically it points to a wrong location or includes a stale NDK version folder that was removed during an SDK update.
Source
Thrown at crates/tauri-cli/src/mobile/android/mod.rs:605
}
Ok(())
}
fn ensure_ndk(non_interactive: bool) -> Result<()> {
// re-evaluate ANDROID_HOME
let android_home = std::env::var_os("ANDROID_HOME")
.or_else(|| std::env::var_os("ANDROID_SDK_ROOT"))
.map(PathBuf::from)
.context("Failed to locate Android SDK")?;
// check NDK_HOME
let mut installed_ndks = if let Some(ndk_home) = std::env::var_os("NDK_HOME") {
let ndk_path = PathBuf::from(ndk_home);
if ndk_path.is_dir() {
vec![ndk_path]
} else {
crate::error::bail!(
"Android NDK invalid. Make sure the NDK_HOME environment variable has correct value."
);
}
} else {
read_dir(android_home.join("ndk"))
.map(|dir| {
dir
.into_iter()
.flat_map(|e| e.ok().map(|e| e.path()))
.collect::<Vec<_>>()
})
.unwrap_or_default()
};
installed_ndks.sort();
if let Some(ndk) = installed_ndks.last() {
log::info!("Using installed NDK: {}", ndk.display());
std::env::set_var("NDK_HOME", ndk);View on GitHub (pinned to 52e4b6e71d)
Solutions
- Point NDK_HOME at an existing NDK directory, e.g. `export NDK_HOME=$ANDROID_HOME/ndk/27.0.0` (pick a folder actually listed by `ls $ANDROID_HOME/ndk`)
- If no NDK is installed, unset NDK_HOME entirely so the CLI can auto-detect or offer to install one
- Restart your shell/CI job after fixing the export so the new value takes effect
Example fix
# before export NDK_HOME="$HOME/Android/Sdk/ndk" # or a removed version # after ls "$HOME/Android/Sdk/ndk" # see installed versions export NDK_HOME="$HOME/Android/Sdk/ndk/27.0.0" # an existing directory
Defensive patterns
Strategy: validation
Validate before calling
if [ -n "$NDK_HOME" ] && [ ! -d "$NDK_HOME" ]; then echo "NDK_HOME points to a missing directory: $NDK_HOME" ls "$ANDROID_HOME/ndk" 2>/dev/null exit 1 fi
Prevention
- Set NDK_HOME from the actual directory listing: export NDK_HOME=$(ls -d $ANDROID_HOME/ndk/* | tail -1)
- Re-export NDK_HOME after upgrading the NDK (versioned folders change)
- Never persist NDK_HOME in committed env files with hard-coded versions that go stale
When it happens
Trigger: NDK_HOME exported but pointing at a nonexistent path, a file instead of a directory, or $ANDROID_HOME/ndk/<old-version> left over from an NDK upgrade that deleted the folder.
Common situations: NDK updated via sdkmanager/Android Studio so the old versioned directory disappeared while the shell/CI env still exports it; typo in the path; trailing quotes or Windows path-style issues in env files.
Related errors
- Android NDK not found. Make sure the NDK is installed and th
- Android SDK not found. Make sure the SDK and NDK are install
- Skipping Android Studio NDK installation. Please go through
- Skipping Android Studio command line tools installation. Ple
- Skipping Android Studio SDK installation. Please go through
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/799da1879c814bfa.
Report an issue: GitHub.