admin管理员组

文章数量:1124801

I'm using Android studio on my windows and running flutter doctor responds with

flutter doctor
Doctor summary (to see all details, run    flutter doctor -v):
[√] Flutter (Channel stable, 3.27.1, on Microsoft Windows [Version 10.0.26100.2605], locale en-GB)

[√] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    X Cannot execute /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home\bin\java to determine the version

[√] Chrome - develop for the web

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)

[√] Android Studio (version 2024.2)

[√] VS Code (version 1.92.2)
[√] Connected device (3 available)
[√] Network resources 

! Doctor found issues in 1 category.

gpt says This error occurs because the system is looking for Java in a macOS path while you're on Windows.

Updating PATH variable to include: %JAVA_HOME%\bin didn't work

I'm using Android studio on my windows and running flutter doctor responds with

flutter doctor
Doctor summary (to see all details, run    flutter doctor -v):
[√] Flutter (Channel stable, 3.27.1, on Microsoft Windows [Version 10.0.26100.2605], locale en-GB)

[√] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    X Cannot execute /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home\bin\java to determine the version

[√] Chrome - develop for the web

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)

[√] Android Studio (version 2024.2)

[√] VS Code (version 1.92.2)
[√] Connected device (3 available)
[√] Network resources 

! Doctor found issues in 1 category.

gpt says This error occurs because the system is looking for Java in a macOS path while you're on Windows.

Updating PATH variable to include: %JAVA_HOME%\bin didn't work

Share Improve this question edited yesterday talex 20.3k3 gold badges33 silver badges68 bronze badges asked 2 days ago Syed Mishkatul HaqueSyed Mishkatul Haque 93 bronze badges 3
  • Where did JAVA_HOME come from? What is its value? – Tim Roberts Commented yesterday
  • /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home\bin\java. It seems like your current path is a mix of / and \. Try updating it in a way that use only one of these. – Reza Farjam Commented yesterday
  • Tried multiple times, didn’t work. If possible, can you share the command? – Syed Mishkatul Haque Commented yesterday
Add a comment  | 

1 Answer 1

Reset to default 0

try updating JAVA_HOME variable

  • Open windows search and write Environment Variables
  • Click on Edit the system environment variables
  • Click the Environment Variables button on bottom
  • Under System Variables or User variables search for JAVA_HOME.
  • if exists update it with your JDK absolute path (just open the folder and click on top to get absolute path)
  • if doesn't exists create a new variable and call it JAVA_HOME and then just enter your JDK absolute path in variable value
  • click OK and apply changes

or you can just enter a command

setx /m JAVA_HOME [your JDK absolute path]

here a example on how to get you jdk absolute path screenshot

本文标签: javaFlutter somehow thinks I39m on macOS even though I39m on WindowsStack Overflow