so I keep getting this error: Your project's Gradle version is incompatible with the Java │ │ version that Flutter is using for Gradle.
Gradle version is 7.5
Im using this kotlin version
ext.kotlin_version = '1.9.23'
tools:
classpath 'com.android.tools.build:gradle:7.3.0'
and java
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
since I was facing the problem I deleted my project and cloned my last working commit, all the above snippets are from this codebase.
but since restore Im still facing the issue, so this is my flutter doctor --verbose for more info, since I had upgraaded by android studio to ladybug and then downgraded it back to flamingo during restore.
Moreover, when I build an apk for android from android studio it successfully creates an apk.
so I keep getting this error: Your project's Gradle version is incompatible with the Java │ │ version that Flutter is using for Gradle.
Gradle version is 7.5
Im using this kotlin version
ext.kotlin_version = '1.9.23'
tools:
classpath 'com.android.tools.build:gradle:7.3.0'
and java
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
since I was facing the problem I deleted my project and cloned my last working commit, all the above snippets are from this codebase.
but since restore Im still facing the issue, so this is my flutter doctor --verbose for more info, since I had upgraaded by android studio to ladybug and then downgraded it back to flamingo during restore.
Moreover, when I build an apk for android from android studio it successfully creates an apk.
Share Improve this question asked Feb 14 at 14:13 IjkIjk 354 bronze badges2 Answers
Reset to default 1I recently deleted my Android Studio (Koala version) and installed Android Studio (Ladybug version). About my Flutter, I also upgraded it, but with command:
$ flutter upgrade
After these, when I tried to run my older Flutter projects, but errors occurred stating incompatibilities between Gradle and Java versions. To fix this, I had to update version informations in two files, namely:
<project_root>/android/settings.gradle
file and,<project_root>/android/gradle/wrapper/gradle-wrapper.properties
.
Update values used in your older project with the values used in a new app created after upgrading Flutter. Example: corresponding to new settings.gradle
file, I updated the older project values from:
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id ".jetbrains.kotlin.android" version "1.7.10" apply false
}
to:
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id ".jetbrains.kotlin.android" version "1.8.22" apply false
}
and in file gradle-wrapper.properties
of the old project, changed the values from:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle./distributions/gradle-7.6.3-all.zip
to:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle./distributions/gradle-8.3-all.zip
and then compiled and ran the project, and this time the errors were fixed and the project ran successfully. You can find the Gradle and Java compatibility information in Compatibility Matrix .
In your case, I can see you are using OpenJDK version 17, so the appropriate Gradle version form the Compatibility Matrix is 7.3
. So, you may have to update file <project_root>/android/gradle/wrapper/gradle-wrapper.properties
to have the appropriate line replaced with:
distributionUrl=https\://services.gradle./distributions/gradle-7.3-all.zip
The simplest solution will be using AGP Upgrade assistant.
In your android studio, Open the
android
folder of your project as a project (File-> Open -> path to android folder of your current project)Wait for the gradle to sync your project (you can see the progress in the bottom right)
Once its completed, Either it will ask you to upgrade your gradle version it will show the errors in the configuration.
Upgrade to the latest version of gradle and sync the project again.
if there is no prompt for upgrading in step 3, Go to tools -> AGP Upgrade Assistant. Then follow the step 4