Skip to content

Commit 1948911

Browse files
committed
Report error better (when encountered weird ndk installation)
1 parent 0f47f04 commit 1948911

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

ndk-build/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use thiserror::Error;
88
pub enum NdkError {
99
#[error(
1010
"Android SDK is not found. \
11-
Please set the path to the Android SDK with the $ANDROID_SDK_ROOT \
11+
Please set the path to the Android SDK with the $ANDROID_HOME \
1212
environment variable."
1313
)]
1414
SdkNotFound,
1515
#[error(
1616
"Android NDK is not found. \
17-
Please set the path to the Android NDK with $ANDROID_NDK_ROOT \
17+
Please set the path to the Android NDK with $NDK_HOME \
1818
environment variable."
1919
)]
2020
NdkNotFound,

ndk-build/src/ndk.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ impl Ndk {
8585
.max()
8686
.ok_or(NdkError::BuildToolsNotFound)?;
8787

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

9193
let build_tag = build_tag
9294
.split('\n')

0 commit comments

Comments
 (0)