Skip to content
Merged
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# native_toolchain_cmake

## 0.2.8
## 0.3.0

- fix: properly resolve user-defines for android_home on Windows, [#37](https://github.com/rainyl/native_toolchain_cmake/issues/37)
- feat: align android SDK and NDK resolver with Flutter's implementation, [#31](https://github.com/rainyl/native_toolchain_cmake/issues/31)
- Breaking change: the Android SDK and NDK resolving logic may be a breaking change

## 0.2.7

Expand Down
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,46 @@ hooks:
ninja_version: null # e.g., "1.10.2"
```

## NDK Discovery

When targeting Android, the NDK root directory is resolved in the following
order (aligned with the Flutter tool's
[AndroidSdk.locateAndroidSdk](https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/android/android_sdk.dart)):

### SDK Root

1. `user_defines.android.android_home` (if set in `pubspec.yaml`)
2. `ANDROID_HOME` environment variable
3. Platform-default install location:
- Linux: `$HOME/Android/Sdk`
- macOS: `$HOME/Library/Android/sdk`
- Windows: `%USERPROFILE%\AppData\Local\Android\Sdk`
4. `<dir>/sdk` fallback (for each hit above: if the directory itself is not a
valid SDK but `<dir>/sdk` is, that subdirectory is used).
5. `aapt` on PATH → `parent.parent.parent` if it looks like an SDK root.
6. `adb` on PATH → `parent.parent` if it looks like an SDK root.

A directory qualifies as an SDK root if it contains a `platform-tools/` or
`licenses/` subdirectory.

### NDK Root

For each SDK root found above:

1. `ANDROID_NDK_HOME` (exact NDK root — highest priority)
2. `ANDROID_NDK_PATH` (fallback when `ANDROID_NDK_HOME` is unset)
3. `ANDROID_NDK_ROOT` (additional fallback)
4. `<sdk>/ndk/<version>/` directories sorted by `Version.parse` in descending
order (latest first; entries that cannot be parsed as a [Version] are
skipped).
5. Linux-only legacy `<sdk>/ndk-bundle/` (single-NDK layout).
6. `ndk-build` on PATH → parent directory (lowest priority).

If `user_defines.android.ndk_version` is specified, only NDK roots whose
basename parses to the requested version are kept; candidates without a
parseable basename (e.g. `ANDROID_NDK_HOME` pointing at a custom-named
directory, or `ndk-bundle`) are skipped.

## Acknowledgements

- [native_toolchain_c](https://pub.dev/packages/native_toolchain_c)
Expand Down
Loading
Loading