Sunday 7 July 2019

Fixing Azure DevOps Xamarine Build error XA5300: The Java SDK Directory could not be found

When you try to build xamarine android projects with Azure Pipelines hosted agent Windows 2019 with VS2019 you might encounter error “XA5300: The Java SDK Directory could not be found”, if you are using a visual studio build task or msbuild task to build a solution which includes android projects. This is caused due to the inability to find the java sdk in the hosted agent. Let’s see how we can get this issue fixed.
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\Host\xxxxxxxxxxxxxxxxxxxxxxxxxxx]

"d:\a\1\s\xxxxxxxxxx.sln" (default target) (1) ->
"d:\a\1\s\Host\xxxxxxxxxxxxx.Android.csproj" (default target) (14) ->
   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.

To fix the issue pass /p:JavaSdkDirectory="$(JAVA_HOME_8_X64)" in msbuild arguments of the visual studio build task.
This will allow the msbuild to find the java sdk and will successfully build your android project.

No comments:

Popular Posts