Reputation: 35
I am currently experiencing an issue with Visual Studio 2022 (Happens on 2019 as well), whenever I create a new Xamarin project, I get these errors.
When I try to configure the existing JDK installation to point to another JDK it does not work. Using the default installed OpenJdk does not work either
Here I am trying to point it to the exisiting JDK that was installed along Visual Studio. I also tried jdk 8 and openjdk 11 13.8.1. I tried changing the JAVA_HOME to point to the appropriate JDK as well, but to no avail.
Under Tools -> Options -> Xamarin, I have this
I am unable to do anything with the "Java Development Kit Location", if I try to point it to any JDK location it will tell me "Cannot find Java Development Kit files in specified path"
The android SDK location points to the SDK that VS installed during the setup.
I have on several occasions tried uninstalling everything related to VS on my computer, but it still did not work
I have tried (not in order):
Any suggestions on how to fix this?
Upvotes: 1
Views: 3380
Reputation: 253
I had the same issue and found that the visual studio installer's log file contained:
[0cd4:0007][2024-07-18T15:06:53] c:\windows\syswow64\\windowspowershell\v1.0\powershell.exe -NoLogo -NoProfile -Noninteractive -ExecutionPolicy Unrestricted -InputFormat None -Command "& """C:\ProgramData\Microsoft\VisualStudio\Packages\OpenJDKv17,version=17.0.8.0,machinearch=x64\AndroidSDKPrivateInstall.ps1""" -Package jdk-17.0.8.101-hotspot -FileName microsoft-jdk-17.0.8.1-windows-x64.zip -Version 17.0.8 -AndroidHome """C:\Program Files (x86)\Android""" -Operation Install; exit $LastExitCode"
[0cd4:0007][2024-07-18T15:06:53] Error: & : AuthorizationManager check failed.
At line:1 char:3
+ & "C:\ProgramData\Microsoft\VisualStudio\Packages\OpenJDKv17,version= ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
It turns out that Windows had blocked this file from executing:
C:\ProgramData\Microsoft\VisualStudio\Packages\OpenJDKv17,version=17.0.8.0,machinearch=x64\AndroidSDKPrivateInstall.ps1
Possibly because I copied Visual Studio's installer files to my computer from a network drive. The installer just failed silently when running it. The trick was to go to the file properties for AndroidSDKPrivateInstall.ps1, de-select readonly, and click unblock.
Then you should be able to run the Visual Studio installer again and install OpenJDK.
Upvotes: 0
Reputation: 1934
Check this guide about setting android sdk on vs https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/android-sdk?tabs=windows
And here is the guide about updating jdk in vs https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/questions/update-jdk?tabs=windows
If you done both and nothing changed you can report the issue as following shows :
Upvotes: 1