Skip to content

Instantly share code, notes, and snippets.

@afandiyusuf
Last active March 25, 2025 00:12
Show Gist options
  • Save afandiyusuf/f6c2d37a1eb7dd01f158fa4cb1b83f1a to your computer and use it in GitHub Desktop.
Save afandiyusuf/f6c2d37a1eb7dd01f158fa4cb1b83f1a to your computer and use it in GitHub Desktop.
Several reminders for me about error that happened to flutter

Flutter JAVA ERROR

Just a reminder that Flutter has the --jdk-dir configuration. If you encounter a Java compatibility error and are certain that you've changed your Java version, make sure to also set the --jdk-dir configuration in Flutter. This happened to me when I installed Android Studio, which comes bundled with Java 21. I received a Java compatibility error despite being sure I had set Java to version 17. I verified it by running the command java --version, which showed that I was using JRE and JDK version 17.

It turns out (I'm not sure why) that Flutter was using Java 21, which comes with the Android SDK, even though I had set my $JAVA_HOME to my local Java installation. It's really strange, though.

You can run flutter config --jdk-dir=$JAVA_HOME to make sure that flutter use java from your JAVA_HOME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment