skip to Main Content

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.

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.

2

Answers


  1. 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]
    
    Login or Signup to reply.
  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

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