{"record":{"id":"811b02127e9f9e28","repo":"tauri-apps/tauri","slug":"android-sdk-not-found-make-sure-the-sdk-and-ndk-a","errorCode":null,"errorMessage":"Android SDK not found. Make sure the SDK and NDK are installed and the ANDROID_HOME and NDK_HOME environment variables are set.","messagePattern":"Android SDK not found\\. Make sure the SDK and NDK are installed and the ANDROID_HOME and NDK_HOME environment variables are set\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-cli/src/mobile/android/mod.rs","lineNumber":523,"sourceCode":"      } else {\n        \"not set\".into()\n      }\n    );\n\n    #[cfg(target_os = \"macos\")]\n    let default_android_home = dirs::home_dir().unwrap().join(\"Library/Android/sdk\");\n    #[cfg(target_os = \"linux\")]\n    let default_android_home = dirs::home_dir().unwrap().join(\"Android/Sdk\");\n    #[cfg(windows)]\n    let default_android_home = dirs::data_local_dir().unwrap().join(\"Android/Sdk\");\n\n    if default_android_home.exists() {\n      log::info!(\n        \"Using installed Android SDK: {}\",\n        default_android_home.display()\n      );\n    } else if non_interactive {\n      crate::error::bail!(\"Android SDK not found. Make sure the SDK and NDK are installed and the ANDROID_HOME and NDK_HOME environment variables are set.\");\n    } else {\n      log::error!(\n        \"Android SDK not found at {}\",\n        default_android_home.display()\n      );\n\n      let extract_path = if create_dir_all(&default_android_home).is_ok() {\n        default_android_home.clone()\n      } else {\n        std::env::current_dir().context(\"failed to get current directory\")?\n      };\n\n      let sdk_manager_path = extract_path\n        .join(\"cmdline-tools/bin/sdkmanager\")\n        .with_extension(if cfg!(windows) { \"bat\" } else { \"\" });\n\n      let mut granted_permission_to_install = false;\n","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-cli/src/mobile/android/mod.rs#L505-L541","documentation":"Thrown by the Tauri CLI's Android environment setup (ensure_android_dev) when ANDROID_HOME/ANDROID_SDK_ROOT are unset or invalid AND the default per-OS SDK location (macOS: ~/Library/Android/sdk, Linux: ~/Android/Sdk, Windows: %LOCALAPPDATA%\\Android\\Sdk) does not exist. In non-interactive mode (--ci) the CLI cannot prompt to download the command line tools, so it aborts immediately instead of offering automatic setup.","triggerScenarios":"Running `tauri android init`, `tauri android dev`, or `tauri android build` with --ci (non_interactive=true) on a machine where ANDROID_HOME and ANDROID_SDK_ROOT are not exported and the default SDK directory does not exist.","commonSituations":"CI runners without the Android SDK preinstalled; fresh machines where Android Studio was never launched (so the SDK directory was never created); ANDROID_HOME exported in an interactive shell profile that CI jobs do not source; the SDK installed in a non-default location.","solutions":["Install the Android SDK via Android Studio (or cmdline-tools) and export ANDROID_HOME and NDK_HOME to its root (e.g. export ANDROID_HOME=$HOME/Android/Sdk, export NDK_HOME=$ANDROID_HOME/ndk/<version>)","Point ANDROID_HOME/ANDROID_SDK_ROOT at an existing SDK: `export ANDROID_HOME=/path/to/sdk`","On CI, use a runner image with the SDK preinstalled (e.g. GitHub's macOS runners ship ~/Library/Android/sdk) or add a setup-android-sdk step before the tauri command","Verify with `sdkmanager --version` or `test -d $ANDROID_HOME` before rerunning `tauri android` commands"],"exampleFix":"# before (CI job, no env)\ntauri android build --ci\n# after\nexport ANDROID_HOME=\"$HOME/Library/Android/sdk\"\nexport NDK_HOME=\"$ANDROID_HOME/ndk/27.0.0\"  # your installed NDK version\ntauri android build --ci","handlingStrategy":"validation","validationCode":"# before running any `tauri android` command in CI:\ntest -n \"$ANDROID_HOME\" && test -d \"$ANDROID_HOME\" || { echo \"ANDROID_HOME missing\"; exit 1; }\ntest -n \"$NDK_HOME\" && test -d \"$NDK_HOME\" || { echo \"NDK_HOME missing\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-install the Android SDK and NDK in your CI image or a setup step instead of relying on tauri's interactive bootstrap","Export ANDROID_HOME and NDK_HOME in the CI job environment (not just your local shell profile)","Validate SDK presence with a guard step that fails fast with a clearer message than the bail"],"tags":["android","sdk","environment","ci","setup","tauri-cli"],"backgroundTag":"android-sdk-not-found","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}