Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using compileSdk 35 requires Android Gradle Plugin (AGP) 8.1.0 or higher: flutter error while building apk release file

[!] Using compileSdk 35 requires Android Gradle Plugin (AGP) 8.1.0 or higher.
│ │  Please upgrade to a newer AGP version. The version of AGP that your project uses is likely defined in:
│ │ /Users/tusharkhatri/Downloads/bmuptodown/android/settings.gradle,
│ │ in the 'plugins' closure.
│ │  Alternatively, if your project was created with an older version of the templates, it is likely
│ │ in the buildscript.dependencies closure of the top-level build.gradle:
│ │ /Users/tusharkhatri/Downloads/bmuptodown/android/build.gradle.
│ │
│ │  Finally, if you have a strong reason to avoid upgrading AGP, you can temporarily lower the compileSdk version in the following file:
│ │ /Users/tusharkhatri/Downloads/bmuptodown/android/app/build.gradle

I expected the APK release file to build.

like image 595
Tushar Khatri Avatar asked Sep 13 '25 16:09

Tushar Khatri


2 Answers

I just ran into the same problem when I upgrade flutter SDK and solve by changing settings.gradle inside /android/ and add those version changes:

plugins {
    id "com.android.application" version "8.1.0" apply false
    id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

And It requires gradle version > 8.0 so change the gradle version inside /android/gradle/wrapper/gradle-wrapper.properties :

.....services.gradle.org/distributions/gradle-8.3-all.zip

After this just run these commands:

flutter clean
flutter pub get
like image 185
Endale one Avatar answered Sep 15 '25 06:09

Endale one


1st solution: delete android folder & recreate it on terminal with:

flutter create .

if u can't for any reason try this 2nd solution: remove the code from the file gradle.setting inside /android

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.1.0" apply false
    id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"

change the gradle version inside /android/gradle/wrapper/gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
like image 27
Abdelrahman Tareq Avatar answered Sep 15 '25 08:09

Abdelrahman Tareq