You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter构建Release APK报错:使用compileSdk 35需AGP 8.1.0或更高

Flutter构建Release APK时AGP版本不兼容问题解决办法

错误信息

[!] 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


解决办法

方法1:升级AGP到8.1.0及以上版本

  • 新模板项目:打开android/settings.gradle,在plugins闭包中修改AGP版本:
    plugins {
        id "com.android.application" version "8.1.0" apply false
        id "com.android.library" version "8.1.0" apply false
        id "org.jetbrains.kotlin.android" version "1.8.10" apply false // Kotlin版本需匹配AGP,可按需调整
    }
    
  • 旧模板项目:打开顶级android/build.gradle,在buildscript的dependencies中修改AGP版本:
    buildscript {
        dependencies {
            classpath "com.android.tools.build:gradle:8.1.0"
        }
    }
    

方法2:临时降低compileSdk版本(不推荐长期使用)

打开android/app/build.gradle,将compileSdkVersion改为34(或其他低于35的兼容版本):

android {
    compileSdkVersion 34

    defaultConfig {
        // 其他原有配置保持不变
    }
}

内容的提问来源于stack exchange,提问作者Tushar Khatri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 18:29:54