简体   繁体   中英

Visual Studio - Cannot find JDK

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):

  • Repaired Visual Studio as the IDE recommends (in order to use the default OpenJdk)
  • Installing OpenJDK and setting the correct PATH and JAVA_HOME prior to installing Visual Studio
  • Installed the appropriate JDK after installing Visual Studio
  • Installing Visual Studio without having JDK on my computer and letting Visual Studio set the PATH to the default installed OpenJdk
  • Installing OpenJDK and letting the JDK set the PATH itself
  • Turning off all malware protection and Windows Firewall before installing Visual Studio
  • I have always checked "javac" and "echo &JAVA_HOME% in the CMD in order to see if everything is working as it should
  • Changing the PATH(s) to point to \bin in the JDK folder

Any suggestions on how to fix this?

Check this guide about setting android sdk on vs https://docs.microsoft.com/en-us/xamarin/android/get-started/installation/android-sdk?tabs=windows

And here is the guide about updating jdk in vs https://docs.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: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM