Skip to content

-t:InstallAndroidDependencies tries to install JDK when no JavaSdkDirectory is specified #9159

@Redth

Description

@Redth

Android framework version

net8.0-android, net9.0-android

Affected platform version

macOS, didn't test windows

Description

The VSCode docs suggest installing the OpenJDK17 by using the installer from the microsoft download page. This installs fine.

However, to get the Android SDK dependencies, the docs suggest using the InstallAndroidDependencies build task.

First of all, it's confusing as it suggests specifying the -p:JavaSdkDirectory variable, which having just installed OpenJDK earlier, it's not clear where that even installed to for me to specify it, so perhaps we shouldn't suggest in the docs to set this variable at all.

I think it's supposed to infer the idk path if I do not specify it, and it seems to do that, however it still appears to try and install the idk to that path, which then fails:

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.99.0-preview.6.340/tools/Xamarin.Installer.Common.targets(19,3): error : Unable to install the Java SDK into `/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home`. Please set `$(JavaSdkDirectory)` to a valid non-administrator path.

Steps to Reproduce

  1. Install openjdk17
  2. Install .NET SDK, and the maui, android workloads.
  3. Try to install the dependencies with the build task:
mkdir ~/mauiandroidtemp && cd ~/mauiandroidtemp
dotnet new android
dotnet build -t:InstallAndroidDependencies \
  -p:AndroidSdkDirectory=/Users/username/Library/Android/sdk \
  -p:AcceptAndroidSDKLicenses=True   

Did you find any workaround?

I can install to a user location such as -p:JavaSdkDirectory=/Users/username/Library/Java/openjdk17 but then I've got an extra jdk

Relevant log output

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions