Skip to content

Commit

Permalink
Report error better (when encountered weird ndk installation)
Browse files Browse the repository at this point in the history
  • Loading branch information
iacore committed Feb 5, 2023
1 parent 0f47f04 commit 1948911
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ndk-build/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use thiserror::Error;
pub enum NdkError {
#[error(
"Android SDK is not found. \
Please set the path to the Android SDK with the $ANDROID_SDK_ROOT \
Please set the path to the Android SDK with the $ANDROID_HOME \
environment variable."
)]
SdkNotFound,
#[error(
"Android NDK is not found. \
Please set the path to the Android NDK with $ANDROID_NDK_ROOT \
Please set the path to the Android NDK with $NDK_HOME \
environment variable."
)]
NdkNotFound,
Expand Down
6 changes: 4 additions & 2 deletions ndk-build/src/ndk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ impl Ndk {
.max()
.ok_or(NdkError::BuildToolsNotFound)?;

let build_tag = std::fs::read_to_string(ndk_path.join("source.properties"))
.expect("Failed to read source.properties");
let Ok(build_tag) = std::fs::read_to_string(ndk_path.join("source.properties")) else {
eprintln!("Failed to read source.properties. Maybe NDK is not at {:?}.", ndk_path);
return Err(NdkError::NdkNotFound);
};

let build_tag = build_tag
.split('\n')
Expand Down

0 comments on commit 1948911

Please sign in to comment.