Gradle插件未找到:'com.android.application'版本8.7.2
Android Gradle Plugin 找不到版本问题处理
错误信息
Error: Build file 'A:\Android\Advertising\build.gradle.kts' line: 2
Plugin [id: 'com.android.application', version: '8.7.2', apply: false] was not found in any of the following sources:
- Try:
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.
- Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.application', version: '8.7.2', apply: false] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.7.2')
Searched in the following repositories:
MavenRepo
相关配置文件
根目录 build.gradle.kts
// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.android) apply false }
libs.version.toml
[versions] agp = "8.7.2" kotlin = "1.9.24" coreKtx = "1.15.0" junit = "4.13.2" junitVersion = "1.2.1" espressoCore = "3.6.1" appcompat = "1.7.0" material = "1.12.0" activity = "1.9.3" constraintlayout = "2.2.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } material = { group = "com.google.android.material", name = "material", version.ref = "material" } androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
问题说明
创建新项目时提示无法找到版本为8.7.2的com.android.application插件,已确认项目配置了Google和MavenCentral仓库,核对过版本号,且未在官方发布说明中找到8.7.2版本。
解决方案
1. AGP 8.7.2版本状态
AGP 8.7.2并非官方发布的版本,当前8.7系列仅有预览版(如8.7.0-alphaXX),不存在8.7.2这个正式或预览版本,因此仓库中无法检索到对应插件。
2. 修复步骤
- 降级到稳定版本:推荐使用AGP 8.6.1,这是当前8.6分支的最新稳定版,兼容性和稳定性均有保障。
- 修改配置:
打开libs.version.toml文件,将agp的版本值改为8.6.1:
保存后同步Gradle项目,等待依赖下载完成即可。[versions] agp = "8.6.1"
3. 版本兼容性说明
你当前使用的Kotlin 1.9.24与AGP 8.6.1完全兼容,无需修改Kotlin版本。
内容的提问来源于stack exchange,提问作者Backi Tech
相关产品推荐
相关产品推荐

