-
Notifications
You must be signed in to change notification settings - Fork 534
JDK 11 Warning
Xamarin.Android 12.0 adds support for Android 12/API-31.
APIs added to Android 12/API-31 may be used by changing the $(TargetFrameworkVersion)
MSBuild property to v12.0
:
<PropertyGroup>
<TargetFrameworkVersion>12.0</TargetFrameworkVersion>
</PropertyGroup>
Building for Android 12/API-31 requires the use of JDK-11 in order to build apps. See the Installing JDK-11 section for details.
However, configuring Visual Studio 2019 or Visual Studio for Mac 8 to use JDK-11 will prevent other features from working correctly. See the JDK 11-Caused Regressions section for details. It will not be possible to target Android 12.0/API-31 and use e.g. the Xamarin.Android Designer at the same time. This will be fixed in a future release.
When Visual Studio 2019 or Visual Studio for Mac 8.10 is configured to use JDK-11, certain Visual Studio features will not work properly.
The Xamarin.Android Designer does not work with JDK-11. When Visual Studio is configured to use JDK-11 and a layout .xml
file is opened within the Xamarin.Android Designer, the renderer will display an error message.
In Visual Studio 2019, the Xamarin.Android Designer will display:
In Visual Studio for Mac 8.10, the Xamarin.Android Designer will display:
JDK-11 will not be installed by default in Visual Studio 2019 and Visual Studio for Mac 8.10.
If Visual Studio is not configured to use JDK-11 and $(TargetFrameworkVersion)
=v12.0, then the build will fail with an XA0031 error:
error XA0031: Java SDK 11.0 or above is required when using $(TargetFrameworkVersion) v12.0.
Note: the Android Designer is incompatible with Java SDK 11.0: https://aka.ms/vs2019-and-jdk-11
If you have not already installed JDK-11, download a JDK-11 installer. We recommend using the Microsoft Build of OpenJDK:
Once an appropriate JDK-11 installer has been downloaded it, install JDK-11.
Once JDK-11 has been installed, the JDK path can be configured within Visual Studio.
Within Visual Studio 2019:
- Click Tools > Options…
- Within the left-hand tree of the Options dialog box, select Xamarin > Android Settings:
- Within the right-hand panel of the Options dialog box, click the … button next to the Java Development Kit Location path. This presents the JDK Configuration dialog box:
- Within the JDK Configuration dialog box, select the Configure an existing JDK installation (Advanced Users) radio button, then click the Browse button.
- Within the Browse For Folder dialog box, navigate to C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot, then click OK.
- Back within the JDK Configuration dialog box, click Continue
- Back within the Options dialog, click OK.
Builds after this point will use JDK-11.
To use JDK 1.8, follow steps (1)…(3), then:
- Within the JDK Configuration dialog box, select the Use the default installed Microsoft OpenJdk radio button, then click Continue.
Within Visual Studio for Mac 8.10:
- Click Visual Studio > Preferences…
- Within the left-hand tree of the the Preferences dialog, select Projects > SDK Locations > Android.
- Within the right-hand panel of the Preferences dialog, select the Locations tab.
- Click the … button to the right of Java SDK (JDK) Location. This opens a directory selection window.
- Within the directory selection window, press Command+Shift+G and Go to the folder /Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home, then click Select Directory.
- Within the Preferences dialog, click OK.
Builds after this point will use JDK-11.
To use JDK 1.8, follow steps (1)…(3), then click the Reset to Defaults button.
- APK Tests on the Hyper V Emulator
- Design Time Build System
- Profile MSBuild Tasks
- Diagnose Fast Deployment Issues
- Preview layout XML files with Android Studio
- Documentation