Skip to content

InstallAndroidDependencies fails with NRE at ResolveAndroidTooling on Mac OS #11394

@mstefarov

Description

@mstefarov

I was setting up a new macbook and ran into problems with InstallAndroidDependencies target. Steps to repro:

  1. Installed latest-stable .NET SDK (10.0.300) from https://dotnet.microsoft.com/en-us/download
  2. Installed maui and android workloads
  3. Installed latest-stable Microsoft OpenJDK (25.0.3 LTS) from https://learn.microsoft.com/en-us/java/openjdk/download
  4. Created a blank MAUI project (dotnet new maui)

Now I called...

dotnet build -t:InstallAndroidDependencies -f:net10.0-android36.0 -p:AndroidSdkDirectory="$HOME/Library/Android/sdk" -p:AcceptAndroidSDKLicenses=True

(per advice from microsoft/vscode-dotnettools#689 (comment) and https://learn.microsoft.com/en-us/dotnet/android/getting-started/installation/dependencies)

And here's the error I got:

testproj % dotnet build -t:InstallAndroidDependencies -f:net10.0-android36.0 -p:AndroidSdkDirectory="$HOME/Library/Android/sdk" -p:AcceptAndroidSDKLicenses=True
  mauinew net10.0-android36.0 failed with 2 error(s) and 5 warning(s) (0.8s)
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/36.1.53/tools/Xamarin.Android.Tooling.targets(58,5): warning XA5300: 
      The Android SDK directory could not be found. Install the Android SDK by following the instructions at: https://ak
      a.ms/dotnet-android-install-sdk
      To use a custom SDK path for a command line build, set the 'AndroidSdkDirectory' MSBuild property to the custom pa
      th.
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/36.1.53/targets/Microsoft.Android.Sdk.Tooling.targets(22,5): warning Value cannot be null. (Parameter 'path1')
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/36.1.53/targets/Microsoft.Android.Sdk.Tooling.targets(22,5): warning XA0034: Failed to get the Java SDK version. Please ensure you have Java 11.0 or above installed.
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/36.1.53/targets/Microsoft.Android.Sdk.Tooling.targets(22,5): warning MSB4181: The "ValidateJavaVersion" task returned false but did not log an error.
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/36.1.53/targets/Microsoft.Android.Sdk.Tooling.targets(35,5): warning XARAT7001: 
      System.NullReferenceException: Object reference not set to an instance of an object.
         at Xamarin.Android.Tasks.ResolveAndroidTooling.RunTask()
         at Microsoft.Android.Build.Tasks.AndroidTask.Execute()
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/36.1.53/tools/Xamarin.Installer.Common.targets(19,3): error Failed to install required Android SDK components.
    /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/36.1.53/tools/Xamarin.Installer.Common.targets(19,3): error XAIAD7003: 
      System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
         at System.ArgumentNullException.Throw(String paramName)
         at System.IO.Path.Combine(String path1, String path2)
         at Xamarin.Installer.AndroidSDK.JavaDependencyInstaller.GetJdkRevision(AndroidRevision& version)
         at Xamarin.Installer.Build.Tasks.InstallAndroidDependencies.InstallJavaSDKAsync(InstallationContext installatio
      nContext, CancellationToken cancellationToken)
         at Xamarin.Installer.Build.Tasks.InstallAndroidDependencies.RunTaskAsync()

Build failed with 2 error(s) and 5 warning(s) in 0.8s

where java and where javac find the binaries at /usr/bin/. The reported version for both is "openjdk 25.0.3" as expected. My macOS is 26.4.1 (arm64). Not sure if I'm doing something wrong, but this smells like a bug.

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions