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

Android Studio Iguana 2023.2.1 Gradle同步失败及插件缺失求助

Android Studio Iguana (2023.2.1) Gradle同步失败:找不到com.android.application插件解决方案

问题详情

  • 新建项目时Gradle同步失败,提示无法定位插件[id: 'com.android.application', version: '8.3.1', apply: false]
  • 项目根目录的build.gradle文件为空
  • 完整错误输出:

Plugin [id: 'com.android.application', version: '8.3.1', 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 from Gradle official documentation
  • Exception is:
    org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.application', version: '8.3.1', 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.3.1')
    Searched in the following repositories:
    Google
    MavenRepo
    Gradle Central Plugin Repository
    [后续堆栈跟踪内容保留原英文]

解决步骤

1. 修正settings.gradle的仓库配置

确保项目根目录的settings.gradle(或settings.gradle.kts)包含正确的仓库声明,Gradle才能找到AGP插件:

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "YourProjectName"
include(":app")

注:将YourProjectName替换为你的实际项目名称

2. 补全根目录build.gradle内容

如果根目录build.gradle为空,添加适配AGP 8.3.1的插件声明:

plugins {
    id("com.android.application") version "8.3.1" apply false
    id("org.jetbrains.kotlin.android") version "1.9.20" apply false
}

若项目使用Java而非Kotlin,可移除org.jetbrains.kotlin.android相关行

3. 排查网络与代理问题

  • 确认网络可正常访问Google、MavenCentral仓库,关闭无关代理
  • 若需使用代理,在Android Studio中配置:File > Settings > Appearance & Behavior > System Settings > HTTP Proxy,确保代理规则允许访问上述仓库

4. 清除Gradle缓存并重启

  • 执行File > Invalidate Caches... > Invalidate and Restart,强制清除缓存并重启IDE
  • 也可手动删除本地Gradle缓存目录:
    • Windows:C:\Users\<你的用户名>\.gradle\caches
    • macOS/Linux:~/.gradle/caches
  • 重启后点击工具栏的Sync Project with Gradle Files按钮重新同步

5. 验证Android Studio组件完整性

  • 打开File > Settings > Appearance & Behavior > System Settings > Android SDK
  • 切换到SDK Tools标签,勾选Show Package Details,确认已安装Android SDK Build-Tools 34.0.0+和Gradle 8.3
  • 若组件缺失,点击Apply安装后重新同步项目

内容的提问来源于stack exchange,提问作者Rafiul Munna

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 16:16:23