Flutter构建失败:无法找到com.android.application 7.3.0插件
Flutter构建失败:无法解析com.android.application:7.3.0插件
问题分析
错误提示无法找到com.android.application:7.3.0插件,核心原因是插件版本与Flutter版本不兼容或官方仓库无法正常访问。
解决方案
1. 匹配Flutter与Android Gradle插件(AGP)版本
不同Flutter版本要求对应AGP版本,先执行flutter doctor查看当前Flutter版本,再调整版本匹配:
| Flutter版本 | 兼容AGP版本 | 兼容Kotlin版本 |
|---|---|---|
| 3.7.x | 7.3.x | 1.7.10 |
| 3.10.x | 7.4.x | 1.8.20 |
| 3.16.x+ | 8.0.x | 1.9.0+ |
2. 修改settings.gradle配置
根据匹配的版本,更新settings.gradle中的插件版本:
plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" // 替换为兼容的AGP版本,示例为Flutter3.10+对应的7.4.2 id "com.android.application" version "7.4.2" apply false // 对应兼容的Kotlin版本 id "org.jetbrains.kotlin.android" version "1.8.20" apply false }
如果是网络无法访问官方仓库,在pluginManagement的repositories中添加国内镜像:
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 } settings.ext.flutterSdkPath = flutterSdkPath() includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") repositories { // 添加阿里云镜像 maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/central' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } google() mavenCentral() gradlePluginPortal() } }
3. 清理缓存并重新构建
执行以下命令彻底清理缓存后重新构建:
flutter clean cd android ./gradlew clean ./gradlew build --refresh-dependencies cd .. flutter run
内容的提问来源于stack exchange,提问作者user3797004
相关产品推荐
相关产品推荐

