From 8481b48b8c0754c80d424df1627258f7e8276ff8 Mon Sep 17 00:00:00 2001 From: AttalliAyoub Date: Fri, 22 May 2026 22:32:07 +0100 Subject: [PATCH] fix: resolve NDK path discovery on Windows --- CHANGELOG.md | 4 ++++ example/pubspec.lock | 2 +- lib/src/locate_ndk.dart | 11 +++++++---- pubspec.yaml | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f837d33..6810cee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.2 + +* Fixed NDK path resolution on Windows by using `USERPROFILE` and normalizing path separators. + ## 0.1.1 * Updated `native_toolchain_c` to `0.18.0`. diff --git a/example/pubspec.lock b/example/pubspec.lock index 5a44f45..27f6009 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: path: ".." relative: true source: path - version: "0.1.0" + version: "0.1.1" archive: dependency: transitive description: diff --git a/lib/src/locate_ndk.dart b/lib/src/locate_ndk.dart index 8fd0895..f190fea 100644 --- a/lib/src/locate_ndk.dart +++ b/lib/src/locate_ndk.dart @@ -378,10 +378,13 @@ class NDKLocator { /// Expands a path template with environment variables and glob patterns. static List expandPath(String pathTemplate) { - final path = pathTemplate.replaceAll( - '\$HOME', - Platform.environment['HOME']!, - ); + // Use platform-dependent environment variables for the user's home directory + final homeDir = Platform.isWindows + ? Platform.environment['USERPROFILE'] ?? '' + : Platform.environment['HOME'] ?? ''; + // Glob requires forward slashes, and USERPROFILE uses backslashes + final normalizedHomeDir = homeDir.replaceAll('\\', '/'); + final path = pathTemplate.replaceAll('\$HOME', normalizedHomeDir); final glob = Glob(path); final matches = glob.listSync(); return matches; diff --git a/pubspec.yaml b/pubspec.yaml index 8064e4d..92ce666 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: android_libcpp_shared description: "Dart / flutter package for Android to add the libc++_shared.so STL C++ shared runtime library to your app" -version: 0.1.1 +version: 0.1.2 homepage: https://zeyus.com/ repository: https://github.com/NexusDynamic/android_libcpp_shared issue_tracker: https://github.com/NexusDynamic/android_libcpp_shared/issues