diff --git a/ndk-build/src/error.rs b/ndk-build/src/error.rs index 9046c85..74da514 100644 --- a/ndk-build/src/error.rs +++ b/ndk-build/src/error.rs @@ -32,6 +32,8 @@ pub enum NdkError { BuildToolsNotFound, #[error("Android SDK has no platforms installed.")] NoPlatformFound, + #[error("Android SDK has no platforms installed between level {0} and {1}.")] + NoPlatformInRange(u32, u32), #[error("Platform `{0}` is not installed.")] PlatformNotFound(u32), #[error("Target is not supported.")] diff --git a/ndk-build/src/ndk.rs b/ndk-build/src/ndk.rs index ca017c2..2f102a9 100644 --- a/ndk-build/src/ndk.rs +++ b/ndk-build/src/ndk.rs @@ -133,13 +133,24 @@ impl Ndk { name.strip_prefix("android-") .and_then(|api| api.parse::().ok()) }) - .filter(|level| (min_platform_level..=max_platform_level).contains(level)) .collect(); if platforms.is_empty() { return Err(NdkError::NoPlatformFound); } + let platforms: Vec = platforms + .into_iter() + .filter(|level| (min_platform_level..=max_platform_level).contains(level)) + .collect(); + + if platforms.is_empty() { + return Err(NdkError::NoPlatformInRange( + min_platform_level, + max_platform_level, + )); + } + Ok(Self { sdk_path, user_home,