7

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 '.\android\settings.gradle' (.\.gradle\caches\6.8.3\scripts\9w4vzv9io97x5h1yfb63h0ld4).
 > 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 .\android\gradle\wrapper\gradle-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)
13
  • It would be recommendable to mention the versions of the products you are using. And the errors. Have you tried changing the version of Gradle or Java to make them compatible? Have you read the requirements of each product?
    – aled
    Commented Apr 27, 2023 at 19:34
  • Yes, I tried changing the version of gradle and Java and it to downgrade but I couldn't fix it, every time came the same problem, if you have good intruction that I fix it, please write me Commented Apr 28, 2023 at 9:46
  • The version of gradle in project is 6.8.3 and the version of Java is 17 Commented Apr 28, 2023 at 9:48
  • You need to provide the rest of the information to help others to help you. Versions of Flutter, Android Studio, etc, errors, configurations.
    – aled
    Commented Apr 28, 2023 at 11:15
  • 1
    Please edit your question to add the missing information from the comments.
    – aled
    Commented Apr 29, 2023 at 13:06

3 Answers 3

15

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!

1
  • works like abaracadabra
    – Zionnite
    Commented Jan 24 at 8:27
3

on your ide project explored Go to android->gradle(not .gradle)->wrapper->gradle-wrapper.properties

and change distribution to distributionUrl=https://services.gradle.org/distributions/gradle-7.6.1-all.zip

or you can change gradle-7.6.1-all to the latest gradle version

1

Change on latest gradle will work

distributionUrl=https://services.gradle.org/distributions/gradle-Latest version-all.zip

Example: distributionUrl=https://services.gradle.org/distributions/gradle-7.6.1-all.zip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.