Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ndk-build/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down
13 changes: 12 additions & 1 deletion ndk-build/src/ndk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,24 @@ impl Ndk {
name.strip_prefix("android-")
.and_then(|api| api.parse::<u32>().ok())
})
.filter(|level| (min_platform_level..=max_platform_level).contains(level))
.collect();

if platforms.is_empty() {
return Err(NdkError::NoPlatformFound);
}

let platforms: Vec<u32> = 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,
Expand Down
Loading