Android Studio Ladybug 2024.2.1运行项目报错:找不到指定插件
问题描述
升级Android Studio至Ladybug 2024.2.1版本后,所有项目均无法运行,报错:
Plugin [id: 'com.android.application', version: '7.6.3', apply: false] was not found in any of the following sources:
当前settings.gradle配置如下:
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 "7.6.3" apply false id "org.jetbrains.kotlin.android" version "1.7.10" apply false } include ":app"
解决方案
- 更新Android Gradle插件(AGP)及Kotlin版本:Android Studio Ladybug(2024.2.1)要求AGP版本最低为8.2.x,7.6.3属于旧版本已被仓库移除。将插件版本替换为适配当前IDE的版本,同时升级Kotlin插件以保证兼容性:
plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "8.2.2" apply false id "org.jetbrains.kotlin.android" version "1.9.20" apply false } - 同步Gradle并清理缓存:点击IDE右上角的「Sync Project with Gradle Files」完成同步,之后执行
File > Invalidate Caches... > Invalidate and Restart清理缓存并重启Android Studio。 - 确认仓库配置有效性:确保
pluginManagement下的repositories列表包含google(),AGP插件仅能从Google仓库获取,不可依赖其他仓库替代。
内容的提问来源于stack exchange,提问作者Nahom Desta
相关产品推荐
相关产品推荐

