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

Android Studio3.0.1+Kotlin1.2.10配置Gradle时POM解析失败求助

Fixing Gradle POM Parsing Error ("Already seen doctype") in Android Studio

Hey there, let's work through this frustrating Gradle configuration issue you're hitting. The "Already seen doctype" error when resolving the com.android.tools.build:gradle:3.0.1 POM usually points to corrupted cached files or incomplete downloads. Here are step-by-step fixes to get your project running again:

1. Clear Gradle Cache & Invalidate Studio Caches

Corrupted cache files are the most common culprit here. Let's wipe them out:

  • Delete Gradle's local cache:
    • On Windows: Go to C:\Users\<YourUsername>\.gradle\caches and delete all contents in this folder (or just the modules-2 subfolder, which stores dependency POMs and jars).
    • On Mac/Linux: Open Terminal and run rm -rf ~/.gradle/caches/modules-2
  • Invalidate Android Studio caches:
    Go to File > Invalidate Caches / Restart, then select Invalidate and Restart. This forces Studio to rebuild its local indexes and re-download dependencies.

2. Verify Repository Configuration

Make sure your project's root build.gradle has the correct repositories listed (and in the right order):
Open the root build.gradle file and check that the buildscript block includes google() and jcenter():

buildscript {
    ext.kotlin_version = '1.2.10-release-Studio3.0-1'
    repositories {
        google() // Prioritize Google's repository first
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

If you're having trouble accessing Google's repository due to network restrictions, you can replace it with a reliable domestic Maven mirror – just ensure the mirror hosts the required Android Gradle plugin artifacts.

3. Re-download Gradle Distribution

Sometimes the Gradle wrapper files get corrupted. Let's refresh them:

  • Open gradle/wrapper/gradle-wrapper.properties and confirm the distributionUrl is set to:
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
    
  • Delete the Gradle wrapper cache folder:
    • Windows: C:\Users\<YourUsername>\.gradle\wrapper\dists\gradle-4.1-all
    • Mac/Linux: rm -rf ~/.gradle/wrapper/dists/gradle-4.1-all
  • Sync your project again (click the "Sync Project with Gradle Files" button in Studio) – this will trigger a fresh download of the Gradle 4.1 distribution.

4. Manually Replace the Corrupted POM File

If none of the above works, you can manually fix the corrupted POM:

  1. Navigate to the cache directory for the Gradle plugin:
    • ~/.gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle/3.0.1/ (the subfolder name will be a hash)
  2. Delete the existing gradle-3.0.1.pom file in that folder.
  3. Get a clean copy of the POM file from a trusted Maven repository and place it in the same folder.
  4. Sync your project once more.

These steps should resolve the POM parsing error and get your Kotlin-based Android app building again!

内容的提问来源于stack exchange,提问作者pouria barani

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:54:11