Search code examples
java.netmauivisual-studio-2022

Visual Studio Fails to Install OpenJDK v8 during .NET MAUI Setup - Access Denied


I've been working on setting up Visual Studio for .NET MAUI development on my Windows computer, but I keep running into a problem during the setup process. The specific issue involves OpenJDK v8 failing to install. This is what I'm seeing:

Couldn't install OpenJDKv8

I've given a few things a shot to move past this, but nothing has worked yet. Here's a quick list of what I've already tried:

  1. Running the Installer as Admin: I ran the Visual Studio Installer with admin rights thinking it might fix a permissions problem. , this didn't work out.
  2. Manual Installation of OpenJDK: I got OpenJDK v8 from AdoptOpenJDK's website and set up the JAVA_HOME variable myself. Even though I could install it on my own, Visual Studio still can't install OpenJDK by itself.
  3. Checking Folder Permissions: I made sure the C:\Program Files\Android\jdk\ folder wasn't set to read-, and I checked that my account has full access. But I'm still stuck.
  4. Clearing the Installer Cache:: I wiped the Visual Studio Installer's cache by getting rid of everything in ProgramData\Microsoft\VisualStudio\Packages, but the install keeps failing.

This is the full error message I got during the installation:

Package 'OpenJDKv8,version=8.0.302.8,chip=x64' failed to install.
Return code: -2147024891
Return code details: Access to the path 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08\bin\klist.exe' is denied.

Install Error:

Something went wrong with the install.

You can troubleshoot the package failures by:

    1. Search for solutions using the search URL below for each package failure
    2. Modify your selections for the affected workloads or components and then retry the installation
    3. Remove the product from your machine and then install again

If the issue has already been reported on the Developer Community, you can find solutions or workarounds there. If the issue has not been reported, we encourage you to create a new issue so that other developers will be able to find solutions or workarounds. You can create a new issue from within the Visual Studio Installer in the upper-right hand corner using the "Provide feedback" button.

================================================================================

Package 'OpenJDKv8,version=8.0.302.8,chip=x64' failed to install.
    Search URL
        https://aka.ms/VSSetupErrorReports?q=PackageId=OpenJDKv8;PackageAction=Install;ReturnCode=-2147024891
    Details
        Return code: -2147024891
        Return code details: Access to the path 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08\bin\klist.exe' is denied.
    Log
        C:\Users\User\AppData\Local\Temp\dd_setup_20240904132622_002_OpenJDKv8.log
    Impacted workloads
        .NET Multi-platform App UI development (Microsoft.VisualStudio.Workload.NetCrossPlat,version=17.11.35102.94)
    Impacted components
        .NET MAUI (Microsoft.VisualStudio.ComponentGroup.Maui.All,version=17.11.35102.94)
        .NET MAUI development tools (Microsoft.VisualStudio.ComponentGroup.Maui.Shared,version=17.11.35102.94)
        .NET MAUI for Android (Microsoft.VisualStudio.ComponentGroup.Maui.Android,version=17.11.35102.94)
        OpenJDK (Microsoft distribution) (Component.OpenJDK,version=17.11.35102.94)

Relevant Log Snippets:

[4100:0009][2024-09-04T13:26:36] Started: Extracting C:\ProgramData\Microsoft\VisualStudio\Packages\OpenJDKv8,version=8.0.302.8,chip=x64\OpenJDK8U-jdk_x64_windows_hotspot_8u302b08.zip to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot
[4100:0009][2024-09-04T13:26:36] Started: Copying file jdk8u302-b08/ASSEMBLY_EXCEPTION to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/ASSEMBLY_EXCEPTION
[4100:0009][2024-09-04T13:26:36] Completed: Copying file jdk8u302-b08/ASSEMBLY_EXCEPTION to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/ASSEMBLY_EXCEPTION
[4100:0009][2024-09-04T13:26:36] Timestamp updated for file 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/ASSEMBLY_EXCEPTION'.
[4100:0009][2024-09-04T13:26:36] Started: Copying file jdk8u302-b08/bin/jrunscript.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jrunscript.exe
[4100:0009][2024-09-04T13:26:36] Completed: Copying file jdk8u302-b08/bin/jrunscript.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jrunscript.exe
[4100:0009][2024-09-04T13:26:36] Timestamp updated for file 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jrunscript.exe'.
[4100:0009][2024-09-04T13:26:36] Started: Copying file jdk8u302-b08/bin/jsadebugd.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jsadebugd.exe
[4100:0009][2024-09-04T13:26:36] Completed: Copying file jdk8u302-b08/bin/jsadebugd.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jsadebugd.exe
[4100:0009][2024-09-04T13:26:36] Timestamp updated for file 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jsadebugd.exe'.
[4100:0009][2024-09-04T13:26:36] Started: Copying file jdk8u302-b08/bin/jstat.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jstat.exe
[4100:0009][2024-09-04T13:26:36] Completed: Copying file jdk8u302-b08/bin/jstat.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jstat.exe
[4100:0009][2024-09-04T13:26:36] Timestamp updated for file 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jstat.exe'.
[4100:0009][2024-09-04T13:26:36] Started: Copying file jdk8u302-b08/bin/jstatd.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jstatd.exe
[4100:0009][2024-09-04T13:26:36] Completed: Copying file jdk8u302-b08/bin/jstatd.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jstatd.exe
[4100:0009][2024-09-04T13:26:36] Timestamp updated for file 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/jstatd.exe'.
[4100:0009][2024-09-04T13:26:36] Started: Copying file jdk8u302-b08/bin/keytool.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/keytool.exe
[4100:0009][2024-09-04T13:26:36] Completed: Copying file jdk8u302-b08/bin/keytool.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/keytool.exe
[4100:0009][2024-09-04T13:26:36] Timestamp updated for file 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/keytool.exe'.
[4100:0009][2024-09-04T13:26:36] Started: Copying file jdk8u302-b08/bin/kinit.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/kinit.exe
[4100:0009][2024-09-04T13:26:36] Completed: Copying file jdk8u302-b08/bin/kinit.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/kinit.exe
[4100:0009][2024-09-04T13:26:36] Timestamp updated for file 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/kinit.exe'.
[4100:0009][2024-09-04T13:26:36] Started: Copying file jdk8u302-b08/bin/klist.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/klist.exe
[4100:0009][2024-09-04T13:26:36] Completed: Copying file jdk8u302-b08/bin/klist.exe to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/klist.exe
[4100:0009][2024-09-04T13:26:36] Timestamp updated for file 'C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08/bin/klist.exe'.
[4100:0009][2024-09-04T13:26:36] Completed: Extracting C:\ProgramData\Microsoft\VisualStudio\Packages\OpenJDKv8,version=8.0.302.8,chip=x64\OpenJDK8U-jdk_x64_windows_hotspot_8u302b08.zip to C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot

System Information:

  • OS: Windows 11 Pro (64-bit)
  • Visual Studio Version: 2022 (Professional Edition, version 17.11.2)
  • .NET SDK Version: 8.0.401
  • Workload: .NET Multi-platform App UI (MAUI)

Has anyone ever experienced this? I wonder if there is a way to bypass the OpenJDK installation entirely through Visual Studio and just set it up manually for Android development in the MAUI. Or am I missing something simple?


Solution

  • Upon digging deeper, I found out that Microsoft Defender Antivirus was behind the problem. In particular, the latest Windows update seemed to have removed the exclusion for C:\Program Files from the Microsoft Defender settings. This resulted in Microsoft Defender stopping access to the folder where OpenJDK was supposed to install leading to the "Access Denied" error during installation.

    Solution:

    I fixed the issue by adding C:\Program Files back to the exclusions in Microsoft Defender Antivirus .

    Here's what I did :

    1. Open Windows Security.
    2. Navigate to Virus & Threat Protection.
    3. Scroll down and select Manage settings under Virus & threat protection settings.
    4. Keep scrolling until you see Exclusions then click Add or remove exclusions.
    5. Include an exclusion for C:\Program Files (or the specific folder for JDK installation).