8

I updated android studio to Electric El, but after updating, it is unable to find Java Runtime.

Flutter doctor gives this error and the code does not compile.

maazaftab@maazs-MacBook-Pro edge-focus-mobile % flutter doctor Doctor summary (to see all details, run flutter doctor -v): The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for information on installing Java. The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for information on installing Java. [✓] Flutter (Channel beta, 3.7.0-1.2.pre, on macOS 13.0.1 22A400 darwin-arm64, locale en-PK) [!] Android toolchain - develop for Android devices (Android SDK version 31.0.0) ✗ Could not determine java version [✓] Xcode - develop for iOS and macOS (Xcode 14.1) [✓] Chrome - develop for the web [!] Android Studio (version 2022.1) ✗ Unable to find bundled Java version. [✓] IntelliJ IDEA Community Edition (version 2022.3) [✓] VS Code (version 1.62.3) [✓] Connected device (2 available) [✓] HTTP Host Availability ! Doctor found issues in 2 categories. 

3 Answers 3

19

In your zshrc file add.

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home 

Restart the android studio. Flutter doctor will give this.

maazaftab@maazs-MacBook-Pro edge-focus-mobile % flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel beta, 3.7.0-1.2.pre, on macOS 13.0.1 22A400 darwin-arm64, locale en-PK) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 14.1) [✓] Chrome - develop for the web [!] Android Studio (version 2022.1) ✗ Unable to find bundled Java version. [✓] IntelliJ IDEA Community Edition (version 2022.3) [✓] VS Code (version 1.62.3) [✓] Connected device (2 available) [✓] HTTP Host Availability 

You can ignore the warning ✗ Unable to find bundled Java version. but the code will compile successfully.

Sign up to request clarification or add additional context in comments.

1 Comment

I've faced the same problem. And this solution works for me link
2

For Mac

  1. Go to finder
  2. Locate Android studio and right-click
  3. Click "Show package contents"
  4. Open contents folder
  5. Open "jdk" folder
  6. Copy the contents folder inside of "jdk" folder
  7. Navigate back to root contents folder
  8. Create a folder named "jre" in the same level of "jdk"
  9. And paste contents folder inside of "jre" folder
  10. Run flutter doctor -v

You are good to go!!!

Comments

0

Open the folder where Android Studio is installed.

In most cases, it is "C:\Program Files\Android\Android Studio"

  1. Open the "jbr" folder inside the Android Studio folder ("C:\Program Files\Android\Android Studio\jbr"), and copy all contents in it.
  2. Then go back and create a new folder called "jre" -> "C:\Program Files\Android\Android Studio\jre"
  3. Paste all contents which you copied from "jbr" folder to "jre" folder.
  4. Click Start and search for "Environment" and open "Edit the Environment variables" from search result.
  5. Click to open "Environment variables"
  6. On "User variables" pane click new and add new variable with name "JAVA_HOME" and path "C:\Program Files\Android\Android Studio\jre". Click OK to save.
  7. Restart Android Studio and run flutter doctor. It will solve the problem.

Android Studio folder screenshot Environment screenshot

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.