I wanted to move my project into Android Studio and when I was running the simulator, the project was running fine. Since I updated Android Studio, the simulator has the error that the Gradle version of the project is not compatible with the Java version.
I would like to know how I can fix the problem gradle version of my project with version 6.8.3 and the compatible version of java version of my PC, I can’t find the compatible version of Java with my project that it could work right I think, because of I upgraded my android studio with it upgraded Java too and I can’t it downgrade again, I wish that you understood now.
Setup:
Gradle 6.8.3
Java 17
Flutter 3.7.12
Android Studio 2022.2.1
Error Message:
FAILURE: Build failed with an exception.
* What went wrong: Could not open settings generic class cache for settings file '.androidsettings.gradle' (..gradlecaches6.8.3scripts9w4vzv9io97x5h1yfb63h0ld4).
> BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 61
To fix this issue, first, check the Java version used by Flutter by running flutter doctor --verbose. Then, update the Gradle version specified in .androidgradlewrappergradle-wrapper.properties to be compatible with that Java version.
Output from java --version
:
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
2
Answers
As you are using java 17, then upgrade gradle to version 7.3 at least.
get idea from Compatibility Matrix.
You can also get version idea from Gradle Release
Go to
Step 1: Go to the gradle directory for your project:
cd android/gradle/wrapper
Step 2: Edit the gradle-wrapper.properties file to change the distribution Url field to the preferred Gradle version (7.3 or others):
distributionUrl=https://services.gradle.org/distributions/gradle-7.6.1-all.zip
Happy Fixing!
hello me I like same problem may it’s on flutter