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

Android Studio同步Gradle报405无法获取gradle-7.0.2.pom如何解决

Gradle同步报405错误解决方案

报错Could not GET 'https://dl.google.com/.../gradle-7.0.2.pom'. Received status code 405 from server: Method Not Allowed是网络链路限制导致Gradle无法正常请求Google官方Maven仓库资源,可按以下步骤依次排查解决:

  • 第一步:关闭无效代理
    打开Android Studio依次进入File > Settings > Appearance & Behavior > System Settings > HTTP Proxy,选择「No proxy」后应用设置,重启Android Studio再尝试同步项目。多数405错误由失效代理、系统代理冲突导致。
  • 第二步:替换为国内镜像源
    根目录build.gradle文件修改为以下配置,用阿里云公共镜像替代官方仓库,同时将预发布版Kotlin插件替换为和AGP 7.0.2适配的稳定版本:
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            // 阿里云Google仓库镜像
            maven { url 'https://maven.aliyun.com/repository/google' }
            // 阿里云Maven中央仓库镜像
            maven { url 'https://maven.aliyun.com/repository/mavencentral' }
            mavenLocal()
        }
        dependencies {
            classpath "com.android.tools.build:gradle:7.0.2"
            // 替换为稳定版Kotlin插件,适配AGP 7.0.2
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    // 全局子模块仓库配置
    allprojects {
        repositories {
            maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/mavencentral' }
            mavenLocal()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
  • 第三步:清理缓存重启
    依次点击File > Invalidate Caches...,勾选「Clear file system cache and local history」后选择「Invalidate and Restart」,等待Android Studio重启后自动同步项目即可。
  • 第四步:排查hosts配置
    若以上步骤都无效,用管理员权限打开记事本,打开路径C:\Windows\System32\drivers\etc\hosts的文件,删除所有包含dl.google.com的映射行,保存后再重启Android Studio同步。

内容的提问来源于stack exchange,提问作者Aarush Soni

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.27 04:36:07