Fix NRE in ResolveAndroidTooling and ValidateJavaVersion when SDK paths are null#11395
Closed
Copilot wants to merge 2 commits into
Closed
Fix NRE in ResolveAndroidTooling and ValidateJavaVersion when SDK paths are null#11395Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…hs are null When the Android SDK or Java SDK directories cannot be found (e.g., during InstallAndroidDependencies on a fresh machine), the ResolveAndroidTooling task would crash with a NullReferenceException because AndroidSdkPath was null when passed to Path.Combine. Similarly, ValidateJavaVersion would throw ArgumentNullException when JavaSdkPath was null. Added null/empty checks: - ResolveAndroidTooling.RunTask(): early return with XA5205 error if AndroidSdkPath is null/empty - ValidateJavaVersion.GetVersionFromTool(): return null if JavaSdkPath is null/empty instead of crashing - ValidateJavaVersion.GetVersionFromFile(): handle null JavaSdkPath and also fix potential null from Path.GetDirectoryName() Fixes #9893 Agent-Logs-Url: https://github.com/dotnet/android/sessions/7cba4bb3-0ff4-4c66-a42b-01d96c8b79c5 Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix InstallAndroidDependencies NRE at ResolveAndroidTooling on Mac OS
Fix NRE in ResolveAndroidTooling and ValidateJavaVersion when SDK paths are null
May 18, 2026
Member
|
Closing in favor of #11321, which uses the correct error code (XA5300) and also guards against the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
InstallAndroidDependenciescrashes with NRE on a fresh machine where Android SDK/Java SDK paths haven't been resolved yet. When_AndroidAllowMissingSdkTooling=True,ResolveSdksfails but the build continues — downstream tasks then receive null paths and crash inPath.Combine.Changes
ResolveAndroidTooling.RunTask(): Early-return with XA5205 error whenAndroidSdkPathis null/empty, preventing NRE atPath.Combine(AndroidSdkPath, "tools", ZipAlign)ValidateJavaVersion.GetVersionFromFile(): Guard against nullJavaSdkPathbeforePath.Combine(JavaSdkPath, "release"); also fix nullable warning fromPath.GetDirectoryName()ValidateJavaVersion.GetVersionFromTool(): Guard against nullJavaSdkPathbeforePath.Combine(JavaSdkPath, "bin", javaExe), returning null instead of throwingArgumentNullException