I have a situation (on Mac) where a Flutter project refuses to build for Android apparently because it is trying to use Android Studio Lady Bug bundled version of Java (which is version 21). It says I should either upgrade the Java Android Plugin to be compatible with Java 21, or use a lower version of Java. I don’t want to change the plugin version because I can pretty much guarantee that will lead to much more “fun.” So I would like to use a separate JDK.
So I downloaded JDK 17 from Adoptium.net and now “java –version” reports 17 (good), and I made JAVA_HOME point to “/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home”… which I thought would cause flutter to detect this.
But when I do “flutter doctor –verbose” it still reflects version 21:
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
• Android SDK at /Users/derp/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
• All Android licenses accepted.
How can I get the flutter build to see/use version 17?
I’m pretty sure that I could just edit the Android Studio settings to point to the alternate (newly installed) JDK, but I don’t want to do that because Android Studio is/should be independent of Flutter development.
Isn’t there some other way to tell Flutter to use a different Java location using flutter cli?
1