Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find bundled Java version #118502

Closed
nguyendviet opened this issue Jan 14, 2023 · 106 comments
Closed

Unable to find bundled Java version #118502

nguyendviet opened this issue Jan 14, 2023 · 106 comments
Labels
customer: crowd Affects or could affect many people, though not necessarily a specific customer. r: fixed Issue is closed as already fixed in a newer version t: flutter doctor Problem related to the "flutter doctor" tool tool Affects the "flutter" command-line tool. See also t: labels. workaround available There is a workaround available to overcome the issue

Comments

@nguyendviet
Copy link

Steps to Reproduce

flutter doctor -v
[!] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

My specs:

Macbook Apple M1
MacOS 13.1 (22C65)
Android Studio Electric Eel | 2022.1.1
java 11.0.16.1 2022-08-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.16.1+1-LTS-1)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.16.1+1-LTS-1, mixed mode)

This is my .zshrc:

export PATH="$PATH:$HOME/flutter/bin"
export JAVA11_HOME=$(/usr/libexec/java_home -v11.0)
export JAVA_HOME=$JAVA11_HOME

I've tried:

This is similar to these tickets but it's not resolved:

@Lavish-Deba
Copy link

hello there, im having same issue on my windows, were you able to resolve this issue ?

@nguyendviet
Copy link
Author

No, I haven't found a solution yet.

@mgenware
Copy link

mgenware commented Jan 15, 2023

Same here on windows after upgrading Android Studio to Electric Eel.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.22621.1105], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    ✗ No Java Development Kit (JDK) found; You must have the environment variable JAVA_HOME set and the java binary in
      your PATH. You can download the JDK from https://www.oracle.com/technetwork/java/javase/downloads/.
[✓] Chrome - develop for the web
[✓] Visual Studio - develop for Windows (Visual Studio Enterprise 2022 17.4.4)
[!] Android Studio (version 2022.1)
    ✗ Unable to find bundled Java version.
[✓] VS Code (version 1.74.3)
[✓] Connected device (4 available)
[✓] HTTP Host Availability

@xyz996
Copy link

xyz996 commented Jan 15, 2023

+1 (Windows 10)
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.19044.2486], locale en-US)
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.1)
[!] Android Studio (version 2022.1)
X Unable to find bundled Java version.

[√] VS Code (version 1.74.3)
[√] Connected device (3 available)
[√] HTTP Host Availability

@305371179
Copy link

same question

@zeqinjie
Copy link
Contributor

zeqinjie commented Jan 15, 2023

me too . look like when i update Android Studio version (2022.1) happen

@roufy235
Copy link

roufy235 commented Jan 15, 2023

Go to finder and find Android studio:

  1. right click and click show package contents
  2. Create a new folder called jre
  3. copy the contents of the jbr folder and paste them into jre folder

reload your terminal and type flutter doctor

@prozenberg
Copy link

@roufy235 I was going crazy with this on macOS, your solution fixed it. Thanks

@1888ael
Copy link

1888ael commented Jan 15, 2023

WINDOWS SOLVED
GO TO
C:\Program Files\Android\Android Studio
then copy the content of jbr and paste the content into jre folder
run doctor again and problem solved

@nguyendviet
Copy link
Author

Thanks a lot @roufy235 That works

Just add a minor thing: both folders: jbr and jre are in <PATH_TO_YOUR_ANDROID_STUDIO>/Android\ Studio/

@Lavish-Deba
Copy link

Thanks a lot @1888ael and @roufy235
I have solved it

@halilbeytorun
Copy link

@roufy235 thanks a lot it solved my problem in Ubuntu 22 also!
Can you explain why do we need to do that?

@junhan-z
Copy link

The fix works, it's a weird fix though...

@Francesco-FL
Copy link

Francesco-FL commented Jan 16, 2023

I agree with @junhan-z.
I understand the "ok doing this works", but why?
Don't we risk solving this problem and provoking others elsewhere? (after all, if the files were in that folder maybe there was a reason)

@robetus
Copy link

robetus commented Jan 16, 2023

Go to finder and find Android studio:

  1. right click and click show package contents
  2. Create a new folder called jre
  3. copy the contents of the jbr folder and paste them into jre folder

reload your terminal and type flutter doctor

Worked on latest macOS but I agree it is weird and I second the question, why?

@nguyendviet
Copy link
Author

nguyendviet commented Jan 16, 2023

Since there are people asking why. I think this is the cause: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/android/android_studio.dart#L449-L451
Credit

The why 🤷

Perhaps a maintainer of the repo can answer that.

@Jago-ral
Copy link

WINDOWS SOLVED GO TO C:\Program Files\Android\Android Studio then copy the content of jbr and paste the content into jre folder run doctor again and problem solved

Tks

@DatabertDuck
Copy link

Thanks @roufy235.
But yeah, leaves an ominous feeling, not knowing if in the we will have to re-install everything completely again :D

@Sar10thak
Copy link

WINDOWS SOLVED GO TO C:\Program Files\Android\Android Studio then copy the content of jbr and paste the content into jre folder run doctor again and problem solved

Thank You So much worked for me.

@GrahamDi
Copy link

GrahamDi commented Jan 16, 2023

Similar things have happened before where the developers of android studio decide to change the directory they keep stuff in for the new version. It then takes Flutter developers a week or two to pick up the issue and to change doctor to look in the new location. I'm sure it will happen again.

Wish the two teams within Google would talk to each other :-)

@aliyazdi75
Copy link

@nguyendviet I think you should keep this issue open, since the suggestion fix is not an actual fix. That's how an issue maintains. It needs to be triaged.

@ber2016
Copy link

ber2016 commented Jan 16, 2023

https://www.youtube.com/watch?v=CKpS9Jij6HQ
solution at least for me

@pnemonic78
Copy link

workaround until official fix:

  1. cd /Applications/Android\ Studio.app/Contents
  2. ln -s jbr jre

@raveesh-me
Copy link

raveesh-me commented Jan 17, 2023

Hello People!
It is the dev's responsibility to declare the right environment variables in their System.
I usually am explicit about these and these lines are added to my .zshrc on mac. The same will work on any Linux machine that uses ZSH.

For windows, use environment variables.

The defaults for me are:

# Export Android Variables
export ANDROID_SDK_ROOT="/Users/raveesh/Library/Android/sdk"
export ANDROID_HOME="/Users/raveesh/Library/Android/sdk"
export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"

In doing this, I just changed JAVA_HOME from:

export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"

to

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

@AntonyLeons
Copy link

I think this issue should not be closed, an update changed the the java home/runtime without notification or a clear error message. users only avoided this error if they had another suitable java version already installed on their system. I had java 17 installed on my system giving me a irrelevant error: java.lang.String java.io.File.path accessible: module java.base does not "opens java.io". its not a good experience.

@kanyshaiosmonova
Copy link

Thank you @roufy235 it works now. I am so thankful
image

@omidshojaee
Copy link

This issue is related to this bug:

https://issuetracker.google.com/issues/247854802

@chops377
Copy link

This helped me, thank you so much. Same issue, android studio updated, lots of stuff broke, patched one by one then got to this issue.

Flutter doctor runs and flutter run runs my app again. Thanks!

@hassnainabass
Copy link

WINDOWS SOLVED GO TO C:\Program Files\Android\Android Studio then copy the content of jbr and paste the content into jre folder run doctor again and problem solved

Thanks. This worked

@bunnyhu
Copy link

bunnyhu commented Feb 16, 2023

mklink /J "f:\Program Files\Android\Android Studio\jre" "f:\Program Files\Android\Android Studio\jbr"

Of course use your path to Android studio.

@hugo-hdsolucoes
Copy link

If you use Microsoft OpenJDK and selected it in the beginning of the installation, you should run this in elevated PowerShell inside Android Studio folder

New-Item -ItemType SymbolicLink -Path ".\jre" -Target "C:\Program Files\Microsoft\jdk-17.0.6.10-hotspot"

@samuelHenriquez92
Copy link

Go to finder and find Android studio:

  1. right click and click show package contents
  2. Create a new folder called jre
  3. copy the contents of the jbr folder and paste them into jre folder

reload your terminal and type flutter doctor

Just ensure that the new jre folder will be at the same level as jbr

@cnksoft
Copy link

cnksoft commented Feb 21, 2023

Excellent solution @roufy235, works perfect.
Thanks a lot.

@this-is-allan
Copy link

Excellent solution @roufy235, thanks.

@eluck
Copy link

eluck commented Feb 22, 2023

Worked for me as well! @roufy235, thanks.

@infinitepower18
Copy link

Several updates were released for flutter and this problem is still a thing? Why? When will it be updated to reflect the changes made to Android Studio?

Also, I did the workaround but find whenever Android Studio updates it removes the jre folder.

@HsynBrnQuenjou
Copy link

baranhuseyinkencu@BARAN-MacBook-Air ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale tr-TR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[!] Android Studio (version 2022.1)
✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
[✓] VS Code (version 1.75.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.
baranhuseyinkencu@BARAN-MacBook-Air ~ % flutter doctor -v
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale tr-TR)
• Flutter version 3.7.5 on channel stable at /Users/baranhuseyinkencu/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c07f788 (2 days ago), 2023-02-22 17:52:33 -0600
• Engine revision 0f359063c4
• Dart version 2.19.2
• DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/baranhuseyinkencu/Library/Android/sdk
• Platform android-33-ext4, build-tools 33.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.75.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.2.1 22D68 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 110.0.5481.100

[✓] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

baranhuseyinkencu@BARAN-MacBook-Air ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.5, on macOS 13.2.1 22D68 darwin-arm64, locale tr-TR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
[✓] VS Code (version 1.75.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found

why do i have "Intellij idea" inside the list.

@timsneath
Copy link
Contributor

timsneath commented Feb 25, 2023

@mariamhas @christopherfujino @itsjustkevin, given the number of thumbs up for this issue, I wonder if it's something we need to patch in the next stable hot fix? As more folk upgrade to Electric Eel, it's going to become considerably more prominent in the next couple of months until the next stable release.

@timsneath timsneath reopened this Feb 25, 2023
@sandwichstealer
Copy link

sandwichstealer commented Feb 25, 2023

Where is the jbr folder located? I have three main folders named 'Android Studio', 'Android Studio1' and 'Android Studio 2'.

I updated Flutter and Android Studio today Feb 25th. So the most current updates don't have a fix going back to Jan 14th. I would like to try publishing my first app ever. Thanks.

@TonyHoyle
Copy link

The delay fixing this means you've now got thousands of people with two copies of java, which may or may not stay in sync.. then you've got those that install a completely different java and override the path to work around the issue..

So a future installer is going to have to try to undo all that without breaking stuff.

@sandwichstealer
Copy link

sandwichstealer commented Feb 25, 2023

workaround until official fix:

  1. cd /Applications/Android\ Studio.app/Contents
  2. ln -s jbr jre

Where is the 'Applications' folder located on a Windows machine?

@giaur500
Copy link

workaround until official fix:

  1. cd /Applications/Android\ Studio.app/Contents
  2. ln -s jbr jre

Where is the 'Applications' folder located on a Windows machine?

On a Windows machinie look in your Android Studio installation directory

@diwacreation3
Copy link

WINDOWS SOLVED GO TO C:\Program Files\Android\Android Studio then copy the content of jbr and paste the content into jre folder run doctor again and problem solved

wow It works finally 🙂❤

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Feb 27, 2023
@darshankawar
Copy link
Member

darshankawar commented Feb 27, 2023

@mariamhas @christopherfujino @itsjustkevin, given the number of thumbs up for this issue, I wonder if it's something we need to patch in the next stable hot fix? As more folk upgrade to Electric Eel, it's going to become considerably more prominent in the next couple of months until the next stable release.

There's already a hotfix request for this issue: #121505 that everyone in this thread can follow-up on for further updates.

I'll keep this issue open for reference and tracking apart from the cp issue linked in this comment. Once the cp is approved and merged, I'll close out this one.

@darshankawar darshankawar added tool Affects the "flutter" command-line tool. See also t: labels. t: flutter doctor Problem related to the "flutter doctor" tool workaround available There is a workaround available to overcome the issue customer: crowd Affects or could affect many people, though not necessarily a specific customer. and removed in triage Presently being triaged by the triage team labels Feb 27, 2023
@andynvt
Copy link

andynvt commented Mar 1, 2023

Works on macOS
This will link jbr folder to jre

cd /Applications/Android Studio.app/Contents
ln -s jbr jre

@giaur500
Copy link

giaur500 commented Mar 1, 2023

Again and again. This is not actually solution, it's workaround only. Next Android Studio update will remove your symlink/folder. So, it can't be considered as solution.

@TonyHoyle
Copy link

TonyHoyle commented Mar 1, 2023 via email

@timsneath
Copy link
Contributor

Thank you all for your comments, and please accept our apologies. This issue was caused by a change in Android Studio after Flutter 3.7 was released.

@giaur500 Correct, this is a workaround. That's why this issue is tagged with the workaround available tag. The details of the fix are here: #121505 and this will be merged in the next hotfix.

@TonyHoyle I'm not sure why you think Google is "being completely inconsistent". As far as I can tell, we've made one comment on this bug, and it's to acknowledge it as a hotfix candidate. A quick reminder: let's be kind and courteous to each other in this professional space.

Closing this issue and locking it since we have the information we need to resolve the bug and a workaround is clearly posted.

@flutter flutter locked as too heated and limited conversation to collaborators Mar 1, 2023
@darshankawar darshankawar added the r: fixed Issue is closed as already fixed in a newer version label Mar 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer: crowd Affects or could affect many people, though not necessarily a specific customer. r: fixed Issue is closed as already fixed in a newer version t: flutter doctor Problem related to the "flutter doctor" tool tool Affects the "flutter" command-line tool. See also t: labels. workaround available There is a workaround available to overcome the issue
Projects
None yet
Development

No branches or pull requests