flutter - Build failed due to the gradle version - Stack Overflow

admin2025-05-02  1

Why I am trying to build the apk, while run the flutter build apk I am getting an error like this

`FAILURE: Build failed with an exception.

  • Where: Build file '/Users/mac/Vista-Learning/Vista-Learning-code-base/App/Mobile apps/YT-fix/vlearning-mobile-app/android/app/build.gradle' line: 31

  • What went wrong: A problem occurred evaluating project ':app'.

Failed to apply plugin 'kotlin-android'. Kotlin Gradle Plugin <-> Android Gradle Plugin compatibility issue: The applied Android Gradle Plugin version (7.2.2) is lower than the minimum supported 7.3.1.

 Please update the Android Gradle Plugin version to at least 7.3.1.
  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at

BUILD FAILED in 1s Running Gradle task 'assembleRelease'... 1,744ms Gradle task assembleRelease failed with exit code 1`

I tried to update the kotlin version and gradle version but still error like Please update the Android Gradle Plugin version

This is my android/build.gradle file

buildscript {
    ext.kotlin_version = '2.1.0'
    repositories {
        google()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        // START: FlutterFire Configuration
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:perf-plugin:1.4.1'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
        // END: FlutterFire Configuration
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url "; }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

And this is my gradle-wrapper.prooerties file

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

I tried to update the gradle version and kotlin version.

Why I am trying to build the apk, while run the flutter build apk I am getting an error like this

`FAILURE: Build failed with an exception.

  • Where: Build file '/Users/mac/Vista-Learning/Vista-Learning-code-base/App/Mobile apps/YT-fix/vlearning-mobile-app/android/app/build.gradle' line: 31

  • What went wrong: A problem occurred evaluating project ':app'.

Failed to apply plugin 'kotlin-android'. Kotlin Gradle Plugin <-> Android Gradle Plugin compatibility issue: The applied Android Gradle Plugin version (7.2.2) is lower than the minimum supported 7.3.1.

 Please update the Android Gradle Plugin version to at least 7.3.1.
  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s Running Gradle task 'assembleRelease'... 1,744ms Gradle task assembleRelease failed with exit code 1`

I tried to update the kotlin version and gradle version but still error like Please update the Android Gradle Plugin version

This is my android/build.gradle file

buildscript {
    ext.kotlin_version = '2.1.0'
    repositories {
        google()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        // START: FlutterFire Configuration
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:perf-plugin:1.4.1'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
        // END: FlutterFire Configuration
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

And this is my gradle-wrapper.prooerties file

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

I tried to update the gradle version and kotlin version.

Share Improve this question asked Jan 2 at 5:42 Krishna prasadKrishna prasad 1451 gold badge2 silver badges13 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

To upgrade gradle version first you have to

update this line :

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

to the desired gradle verion in the gradle-wrapper.properties file. Then in the terminal you have to type

cd android

followed with

./gradlew

by doing this you can upgrade gradle version

Change the com.android.tools.build:gradle version to 7.3.1 in android/build.gradle:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        // Other classpath dependencies
    }
}

Then change the gradle version to a compitable version, in gradle/wrapper/gradle-wrapper.properties like 7.6.3:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip

Then

flutter clean
flutter pub get
flutter run -d [DEVICE]
转载请注明原文地址:http://www.anycun.com/QandA/1746132863a92028.html