Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Fixes: http://feedback.devdiv.io/606218

Something has happened with Xamarin.Android builds running on Azure
DevOps recently, builds are now failing with:

ResolveSdks
    ...
Errors
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(721,2): error XA5300: The Java SDK Directory could not be found. Please set via /p:JavaSdkDirectory. [d:\a\1\s\Xamarin.Android.Lite\Xamarin.Android.Lite.csproj]

Azure DevOps has posted a "workaround" document:

https://github.com/microsoft/azure-pipelines-image-generation/blob/1371aa8548aa135c3be783bd854681118ca10f78/images/win/Vs2019-Server2019-Readme.md#known-issues

It suggests adding this property to MSBuild calls:

/p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"

Reviewing a user's build log from ReactiveUI:

https://dev.azure.com/dotnet/ReactiveUI/_build/results?buildId=18505

/p:JavaSdkDirectory=C:/Program%20Files/Java/zulu-8-azure-jdk_8.38.0.13-8.0.212-win_x64

So I tried this with my own repo that has Azure DevOps configured,
sure enough a build from June 18, 2019 worked. A rebuild on July 1,
2019 failed with the reported error.

I can read from the build logs that both JAVA_HOME and
JAVA_HOME_8_X64 are set to:

C:/Program Files/Java/zulu-8-azure-jdk_8.38.0.13-8.0.212-win_x64

I think this means two things:

  • Microsoft Open JDK is no longer installed on the Hosted Windows 2019 with VS2019 pool.
  • Instead, yet another JDK called the Azul Zulu JDK is present...

https://docs.microsoft.com/en-us/java/azure/jdk/java-jdk-install?view=azure-java-stable

I think we should add a "last resort" lookup for a valid JDK within
JAVA_HOME on Windows. It does not currently do that.

Reviewing the code, I am somewhat confused by JdkInfo. Its logic is
not run on Windows, and instead we have Windows-specific JDK lookups
in AndroidSdkWindows. To make things work properly we can just add a
last chance lookup for JAVA_HOME in AndroidSdkWindows.

I also cleaned up the tests a bit: CreateFauxJavaSdkDirectory was
not setting up jar.exe or jvm.dll.

Fixes: http://feedback.devdiv.io/606218

Something has happened with Xamarin.Android builds running on Azure
DevOps recently, builds are now failing with:

    ResolveSdks
        ...
    Errors
        C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(721,2): error XA5300: The Java SDK Directory could not be found. Please set via /p:JavaSdkDirectory. [d:\a\1\s\Xamarin.Android.Lite\Xamarin.Android.Lite.csproj]

Azure DevOps has posted a "workaround" document:

https://github.com/microsoft/azure-pipelines-image-generation/blob/1371aa8548aa135c3be783bd854681118ca10f78/images/win/Vs2019-Server2019-Readme.md#known-issues

It suggests adding this property to MSBuild calls:

    /p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"

Reviewing a user's build log from ReactiveUI:

https://dev.azure.com/dotnet/ReactiveUI/_build/results?buildId=18505

    /p:JavaSdkDirectory=C:/Program%20Files/Java/zulu-8-azure-jdk_8.38.0.13-8.0.212-win_x64

So I tried this with my own repo that has Azure DevOps configured,
sure enough a build from June 18, 2019 worked. A rebuild on July 1,
2019 failed with the reported error.

* Worked: https://jopepper.visualstudio.com/Jon%20Peppers%20OSS/_build/results?buildId=208
* Failed: https://jopepper.visualstudio.com/Jon%20Peppers%20OSS/_build/results?buildId=209

I can read from the build logs that both `JAVA_HOME` and
`JAVA_HOME_8_X64` are set to:

    C:/Program Files/Java/zulu-8-azure-jdk_8.38.0.13-8.0.212-win_x64

I think this means two things:

* Microsoft Open JDK is no longer installed on the `Hosted Windows
  2019 with VS2019` pool.
* Instead, *yet another JDK* called the Azul Zulu JDK is present...

https://docs.microsoft.com/en-us/java/azure/jdk/java-jdk-install?view=azure-java-stable

I think we should add a "last resort" lookup for a valid JDK within
`JAVA_HOME` on Windows. It does not currently do that.

Reviewing the code, I am somewhat confused by `JdkInfo`. Its logic is
not run on Windows, and instead we have Windows-specific JDK lookups
in `AndroidSdkWindows`. To make things work properly we can just add a
last chance lookup for `JAVA_HOME` in `AndroidSdkWindows`.

I also cleaned up the tests a bit: `CreateFauxJavaSdkDirectory` was
not setting up `jar.exe` or `jvm.dll`.
@dotnet dotnet deleted a comment from azure-pipelines bot Jul 1, 2019
@dotnet dotnet deleted a comment from azure-pipelines bot Jul 1, 2019
I can't actually run this test on CI, since our current CI machines have the Microsoft Open JDK installed.
@jonathanpeppers jonathanpeppers merged commit 9b03310 into dotnet:master Jul 2, 2019
@jonathanpeppers jonathanpeppers deleted the windows-java_home branch July 2, 2019 03:07
mattleibow added a commit to mattleibow/square-bindings that referenced this pull request Aug 5, 2019
mattleibow added a commit to mattleibow/square-bindings that referenced this pull request Aug 5, 2019
* Update the build system
 - use new SDK-style projects
 - use msbuild pack
 - use newer bots
* Make sure the Aardvark bindings are up-to-date
* Xamarin.Android does not fall back to JAVA_HOME
 - dotnet/android-tools#74
* Update badge
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

Successfully merging this pull request may close these issues.

2 participants