I've installed .NET 6 (version 6.0.100-rc.1.21458.32) and Visual Studio 2020 Preview (although it might be not a prerequisite).
I am trying to debug a hello-world application but I am getting a build error regarding Java.
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.100-rc.1.12\targets\Microsoft.Android.Sdk.Tooling.targets(20,5): error XA0031:
Java SDK 11.0 or above is required when using .NET 6 or higher.
I've installed Java 17 setting Path
as well as pointing to the Java Development Kit Location in Visual Studio settings (tools->options->Xamarin->Android Settings). Because that didn't work I've set the JDK location to Microsoft's openjdk, but it still doesn't work.
What's wrong here?
For example, to develop applications in Java, you need a Java SDK (JDK). SDKs contain binaries, source code for the binaries, and documentation for the source code. JDK builds also contain annotations. Generally, SDKs are global.
There's no difference between JDK and Java SDK. Both of them mean the same thing.
Installing Microsoft's OpenJDK 11 did the job for me.
You may notice that Visual Studio installs a version of Microsoft OpenJDK, however, you need to install the Microsoft OpenJDK 11
When I installed VS2022 preview 4, my configuration became C:\Program Files\Microsoft\jdk-11.0.10.9-hotspot
This can be fixed for you if you run the maui-check
command (if you installed that component during visual studio installation).
If you don't have the maui-check
tool, you can get it by running the dotnet tool install -g Redth.Net.Maui.Check
command
Maybe you skipped a step during installation and that's why you get the error.
Here's how I got it working on macOS with Visual Studio for Mac.
On macOS, install the Microsoft Open JDK using HomeBrew:
brew install --cask microsoft-openjdk
In Visual Studio for Mac, select Visual Studio -> Preferences.
In the Preferences window, navigate to SDK Locations -> Android -> Locations.
In the Java SDK (JDK) Location: text box, enter the following:
/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With