Skip to main content

Command Palette

Search for a command to run...

🚀 Fixing Java JDK Issues in Flutter & Android Studio on macOS (2025)

Updated
2 min read
🚀 Fixing Java JDK Issues in Flutter & Android Studio on macOS (2025)

🛑 Problem:

• Android Studio was not detecting the correct Java version.

• flutter doctor kept showing wrong Java version (JDK 21 instead of JDK 17).

• Creating a new Flutter project resulted in a Java project instead of Flutter.

• Setting Java manually in Android Studio via Choose Boot Java Runtime didn’t persist.

• Android Studio showed “Unable to find bundled Java version”.

✅ Step-by-Step Fix:

1️⃣ Set Flutter to Use the Correct JDK

Run this command in the terminal:

flutter config --jdk-dir="/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home"

• This ensures Flutter uses JDK 17 instead of whatever Studio is forcing.

2️⃣ Restart Everything

• Close Android Studio completely.

• Restart your Mac to make sure the settings apply properly.

3️⃣ Verify the Fix

Run:

flutter doctor -v

Check for this output under Android toolchain:

Java binary at: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java
Java version OpenJDK Runtime Environment Temurin-17.0.14+7

✅ If it shows this, you’re good! 🎉

🔄 Extra Fixes (If Issues Continue)

🔹 Reset Flutter & Android Studio Paths

flutter config --clear

Then reconfigure:

flutter config --jdk-dir="/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home"

Restart Mac again.

🔹 Reinstall Flutter & Android Studio

• Uninstall and reinstall Flutter via Homebrew:

brew uninstall --cask flutter && brew install --cask flutter

brew uninstall --cask flutter && brew install --cask flutter

• Reinstall Android Studio

🔹 Ensure Plugins Are Installed

• Open Android Studio and install the Flutter & Dart plugins.

🎉 Conclusion

✅ After these steps, Flutter & Android Studio now work correctly with JDK 17. No more weird Java issues or accidental Java projects! 🚀

💡 Save this doc for the future! Never waste another whole day fixing this! 😭🔥

More from this blog

B

Bhavik Bhuva’s Tech Insights: Full Stack Development, Flutter Developer, and More

7 posts

Code With Bhavik