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

Flutter运行报错:无法解析org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10

解决Flutter run时POM文件解析失败(Content is not allowed in prolog)的问题

问题描述

已完成Flutter、Android Studio、Java的安装与环境变量配置,安卓虚拟机正常,创建首个应用后执行flutter run命令时,出现依赖解析失败报错,核心提示为Content is not allowed in prolog,无法解析org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10及io.flutter:flutter_embedding_debug的POM文件。重装Flutter和Android Studio后问题仍存在,完整报错信息如下:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
[Fatal Error] flutter_embedding_debug-1.0.0-2e4ba9c6fb499ccd4e81420543783cc7267ae406.pom:2:1: Content is not allowed in prolog.
[Fatal Error] kotlin-stdlib-jdk8-1.7.10.pom:2:1: Content is not allowed in prolog.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10.
     Required by:
         project :app
      > Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10.
         > Could not parse POM https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.7.10/kotlin-stdlib-jdk8-1.7.10.pom
            > Content is not allowed in prolog.
   > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-2e4ba9c6fb499ccd4e81420543783cc7267ae406.
     Required by:
         project :app
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-2e4ba9c6fb499ccd4e81420543783cc7267ae406.
         > Could not parse POM https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-2e4ba9c6fb499ccd4e81420543783cc7267ae406/flutter_embedding_debug-1.0.0-2e4ba9c6fb499ccd4e81420543783cc7267ae406.pom
            > Content is not allowed in prolog.

* Try:
> Run with --stacktrace option to get the stack trace.
> 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

BUILD FAILED in 3s
Error: Gradle task assembleDebug failed with exit code 1

解决方案

  • 清理Gradle缓存
    本地Gradle缓存中的POM文件可能已损坏,直接删除缓存目录:

    • Windows:删除C:\Users\<你的用户名>\.gradle\caches文件夹
    • Mac/Linux:删除~/.gradle/caches文件夹
      删除后重新执行flutter run,Gradle会重新下载完整的依赖文件。
  • 检查网络代理与镜像配置
    代理或不稳定的镜像可能导致下载的POM文件为无效内容(如网页跳转代码):

    1. 暂时关闭系统代理或VPN,重新尝试构建
    2. 检查项目android/build.gradle中的仓库配置,确保使用官方或可靠源:
      repositories {
          google()
          mavenCentral()
      }
      
  • 手动替换损坏的POM文件

    1. 复制报错中对应的POM链接,在浏览器中打开,确认能正常获取XML格式的文件
    2. 下载该POM文件
    3. 找到Gradle缓存中对应路径(例如.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.7.10/<哈希值>/),替换已损坏的POM文件
    4. 重新执行flutter run
  • 升级Kotlin版本
    旧版本Kotlin的POM可能存在兼容性问题,升级项目中的Kotlin版本:

    1. 打开项目android/build.gradle文件
    2. 修改ext.kotlin_version为较新的稳定版本,例如:
      buildscript {
          ext.kotlin_version = '1.8.20'
          repositories {
              google()
              mavenCentral()
          }
          // 其他内容保持不变
      }
      
    3. 执行flutter clean清理项目缓存,再执行flutter run

内容的提问来源于stack exchange,提问作者Tam Nguyen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 00:10:54