skip to Main Content

I think I have a problem with my flutter installation, or at least a conflict with the versions of Android Studio. Whenever I create a new Flutter project, I receive this advise:

The configured version of Java detected may conflict with the Gradle version in your new Flutter
app.

To keep the default AGP version Gradle version 8.3, download a compatible Java version
(Java 17 <= (Java 17 <= compatible Java version < Java 21) Java version < Java 21). Configure this
Java version
globally for Flutter by running:

  flutter config --jdk-dir=<JDK_DIRECTORY>


Alternatively, to continue using your configured Java version, update the Gradle
version specified in the following file to a compatible Gradle version (compatible Gradle version
range: 8.4 - 8.7):
C:UsersInteliDesktopFlutterProjectsdeliveryandroid/gradle/wrapper/gradle-wrapper.properties

You may also update the Gradle version used by running
`./gradlew wrapper --gradle-version=<COMPATIBLE_GRADLE_VERSION>`.

See
https://docs.gradle.org/current/userguide/compatibility.html#java for details
on compatible Java/Gradle versions, and see
https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:upgrading_wrapper
for more details on using the Gradle Wrapper command to update the Gradle version
used.

This message basically says to me that my Java version (the Java that is installed with Android Studio, that in my case is Java 21) is incompatible to the version of the gradle (who by default its the version 8.3) in the flutter project, making it impossible to compile in Android devices.

The solution was basically update the gradle to the version 8.5, who is the compatible version to the Java 21. To achieve this, i go to the /android folder in my flutter project and run the command:

./gradlew wrapper --gradle-version=8.5

My problem is that everytime I create a new Flutter project I have to repeat this proccess.

Anyone knows how to permanently solves this problem? Or at least change the default template to directly download the gradle 8.5 instead of 8.3

2

Answers


  1. The main conflict occurs from the inclusion of Java version 21 in the Ladybug update in android studio, which causes incompatibilities with Flutter and necessitates updating the Android Gradle.

    So as of now you can downgrade your android studio version and try.

    OR

    Downgrade your java version and try.

    Login or Signup to reply.
  2. FWIW, I have been having similar problems
    and lately have had sucessful builds using

    • Android Studio Ladybug | 2024.2.1 Patch 3
    • OpenLogic JDK 22 aka OpenLogicjdk-22.0.2.9-hotspot
    • gradle-8.3_all.zip

    See also your /android/gradle/gradle.wrapper.properties file for gradle’s distributionUrl property

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search