my case, on Windows 10, my JAVA_HOME was set to JAVA SE 16 C:\Program Files\Java\jdk-16 and when I looked at the release file in java jre in android studio, C:\Program Files\Android\Android Studio\jre\release, I found that the the JAVA_VERSION WAS "11.0.10" (java 11) for short. So I changed the java installation on my PC to Java 11, update JAVA_HOME in my environment variables to point to the new java (C:\Program Files\Java\jdk-11.0.12) and restarted android studio, Then everything worked.

removed the JAVA_HOME path to the JAVA download and changed JAVA_HOME path to the following:

C:\Program Files\Android\Android Studio\jre

this error occurs, this might because you have installed the latest JDK such as JDK 16. You download and install JDK 8 and uninstall JDK 16. Then restart the desktop/laptop and try launch and run flutter run again. 

should be working fine.

Java JDK 16 is the one that seems to lead to this issue try downgrading by downloading a lower version of JDK preferable JDK 8 or 11

To future individuals who will run to this error. Here is the link to download the JDK enjoy your coding experience don't forget to change the path too.

added this line to ./android/ for OSX:

need to update version of Gradle:

  1. go to and get info about last version (for now it is 7.1.1)
  2. open gradle/wrapper/ and change version to last


 Windows 10, set the JAVA_HOME environment variable to the JRE for Android Studio. For example:

C:\Program Files\Android\Android Studio\jre

Gradle "Could not open buildscript class cache"


go to location ".gradle\caches\2.0\scripts\build_7l4t45nbnsvdcl79ol8u0beli4\ProjectScript" and remove file


xception typically occurs due to corrupted cache files.

Deleting the cache do work in most cases.


rm -rf ~/.gradle/caches


Delete the %USER_HOME%.gradle/caches folder