Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentException looking for JDKs #154

Open
jonathanpeppers opened this issue Feb 15, 2022 · 1 comment
Open

ArgumentException looking for JDKs #154

jonathanpeppers opened this issue Feb 15, 2022 · 1 comment

Comments

@jonathanpeppers
Copy link
Member

This happened in a test here:

23:21:22.063   1:7>/Users/runner/android-toolchain/dotnet/packs/Microsoft.Android.Sdk.Darwin/31.0.200-ci.pr.gh6745.77/tools/Xamarin.Android.Tooling.targets(69,5): warning : An exception occurred while validating the Java SDK installation in '/Users/runner/Library/Android/jdk-11' that was found while searching the paths from '$JI_JAVA_HOME'. Ensure that the Android section of the Visual Studio options has a valid Java SDK directory configured. To use a custom SDK path for a command line build, set the 'JavaSdkDirectory' MSBuild property to the custom path. Exception: Not a directory (Parameter 'homePath') [/Users/runner/work/1/a/TestRelease/02-14_22.59.11/temp/NothingToBindclass-parse/UnnamedProject.csproj]
                     System.ArgumentException: Not a directory (Parameter 'homePath')
                        at Xamarin.Android.Tools.JdkInfo..ctor(String homePath, String locator, Action`2 logger) in /Users/builder/azdo/_work/2/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs:line 57
                        at Xamarin.Android.Tools.JdkInfo..ctor(String homePath, String locator) in /Users/builder/azdo/_work/2/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs:line 97
                        at Xamarin.Android.Tools.JdkInfo.TryGetJdkInfo(String path, Action`2 logger, String locator) in /Users/builder/azdo/_work/2/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs:line 347 (TaskId:57)

The MSBuild log says $JI_JAVA_HOME is:

JI_JAVA_HOME = /Users/runner/Library/Android/jdk-11
@jonpryor
Copy link
Member

Odds are that $JI_JAVA_HOME, while set, does not exist:

if (!Directory.Exists (homePath))
throw new ArgumentException ("Not a directory", nameof (homePath));

internal static JdkInfo? TryGetJdkInfo (string path, Action<TraceLevel, string> logger, string locator)
{
JdkInfo? jdk = null;
try {
jdk = new JdkInfo (path, locator);
}
catch (Exception e) {
logger (TraceLevel.Warning, string.Format (Resources.InvalidJdkDirectory_path_locator_message, path, locator, e.Message));
logger (TraceLevel.Verbose, e.ToString ());
}
return jdk;
}

<data name="InvalidJdkDirectory_path_locator_message" xml:space="preserve">
<value>An exception occurred while validating the Java SDK installation in '{0}' that was found while searching the paths from '{1}'. Ensure that the Android section of the Visual Studio options has a valid Java SDK directory configured. To use a custom SDK path for a command line build, set the 'JavaSdkDirectory' MSBuild property to the custom path. Exception: {2}</value>
<comment>
{0} - The path of the invalid installation
{1} - a "contextual" name for where {0} came from: `Preferred Registry` (Windows Registry), `OpenJDK`, `$JAVA_HOME` (environment variable), etc.
{2} - The exception message of the associated exception.</comment>
</data>

Feels like the test environment is probably broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants