# 🚀 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:

```bash
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:

```bash
flutter doctor -v
```

Check for this output under **Android toolchain**:

```bash
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**

```bash
flutter config --clear
```

Then reconfigure:

```bash
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

```bash
brew uninstall --cask flutter && brew install --cask flutter
```

• Reinstall **Android Studio**

🔹 **Ensure Plugins Are Installed**

• Open Android Studi[o and](https://developer.android.com/studio) install the **Flutter** & **Dart** pl[ugin](https://developer.android.com/studio)s.

**🎉 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! 😭🔥
