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

Android Studio无法找到com.android.application:8.2.0插件求助

问题描述
  • 从Android Studio Flamingo升级到Hedgehog版本后,新建项目必触发同步错误
  • 当前配置:最新Java JDK、Gradle 8.1、AGP版本8.2.0
  • 错误信息:

Build file 'C:\Users\Mohit Dhote\AndroidStudioProjects\MyApplication2\build.gradle.kts' line: 5
Plugin [id: 'com.android.application', version: '8.2.0', 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.2.0', apply: false] was not found in any of the following sources:
  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.2.0')
    Searched in the following repositories:
    Google
    MavenRepo
  • 已尝试更换Gradle版本、升级JDK,问题未解决
解决方案

1. 修正仓库配置顺序

打开项目根目录的settings.gradle.kts,确保google()仓库在mavenCentral()之前声明,AGP插件优先从Google仓库拉取:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal() // 补充Gradle插件仓库
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

2. 匹配AGP与Gradle的兼容版本

AGP 8.2.0官方推荐搭配Gradle 8.2版本,修改gradle/wrapper/gradle-wrapper.properties文件:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip

3. 清理Gradle缓存

  • 关闭Android Studio
  • 删除本地Gradle缓存目录:C:\Users\<你的用户名>\.gradle\caches
  • 重新打开项目,点击工具栏的「Sync Project with Gradle Files」

4. 排查代理网络问题

如果使用代理,确保Gradle能正常访问Google仓库:

  • 在项目根目录的gradle.properties中添加代理配置(按需填写):
systemProp.http.proxyHost=你的代理IP
systemProp.http.proxyPort=代理端口
systemProp.https.proxyHost=你的代理IP
systemProp.https.proxyPort=代理端口
  • 若无需代理,直接关闭系统代理或Gradle代理配置

5. 手动指定插件完整坐标

在项目根目录的build.gradle.kts中,尝试用完整坐标声明插件:

plugins {
    id("com.android.application") version "8.2.0" apply false
}

内容的提问来源于stack exchange,提问作者27_mohit _dhote_2B

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 01:41:22