Fixing `An exception has occurred in the compiler (1.8.0_242-release)`

Today my Flutter project failed to compile with the following error:

An exception has occurred in the compiler (1.8.0_242-release). Please file a bug against the Java compiler via the Java bug reporting page ( after checking the Bug Database ( for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class$NameImpl)

A quick Google search returns those two posts:

So I ran flutter doctor and got this:

Everything looks fine except for some Android toolchain and Xcode issues, which seem inconsequential. Still, I'll update Android Studio as suggested. I opened Android Studio, clicked onto "Check Updates" and clicked on what it suggested to me. Some Android Studio Preview. After installing it, I ran flutter doctor -v again and got this:

Now it can't even find a bundled Java version...

I tried compiling again, and it gave me the same error, meaning that it's still using OpenJDK version 1.8.0_242-release.

I tried installing Oracle's JDK, but compilation does not use it.

So I went to to download the latest build of OpenJDK. But the tar file contains just the files, not an installer. I don't want to have to read the docs on how to install it, where to unpack it, what new paths or virtual links to set up.

Another blind try, installing a few more SDK components in Android Studio.

But it did not change a thing. So I uninstalled Android Studio Preview and decided to go for the stable version at And this time it worked!

And it finally compiled my app.