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

libGDX构建HTML端报错:Failed to notify project evaluation listener

libGDX HTML构建及SuperDev任务失败问题解决

错误现象

执行gradle html:dist或gradle html:superDev时触发以下错误:

Configure project :html
GWT version is < 2.5 -> additional dependencies are not added.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':html'.
Failed to notify project evaluation listener.
org/gradle/api/internal/artifacts/dsl/dependencies/DependencyFactory$ClassPathNotation

甚至执行gradle html:clean也会触发该错误。更新Gradle版本后问题更严重,需注释HTML模块的构建配置才能正常运行gradle desktop:run。

当前配置

根目录build.gradle依赖:

dependencies {
    classpath 'com.badlogicgames.gdx:gdx-tools:1.11.0'
    classpath 'org.wisepersist:gwt-gradle-plugin:1.1.19'
    classpath 'org.gretty:gretty:3.0.7'
    classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.16'
    classpath 'com.android.tools.build:gradle:3.6.1'
    classpath 'com.google.gms:google-services:4.3.2'
}

根目录build.gradle全局变量:

allprojects {
apply plugin: "eclipse"

version = '1.0'
ext {
    appName = "tileShipGame"
    gdxVersion = '1.11.0'
    roboVMVersion = '2.3.16'
    box2DLightsVersion = '1.5'
    ashleyVersion = '1.7.4'
    aiVersion = '1.8.2'
    gdxControllersVersion = '2.2.1'
}

HTML模块html/build.gradle配置:

gwt {
gwtVersion='1.11.0' // Should match the gwt version used for building the gwt backend
...
}

已尝试的操作

  • 对齐根目录与HTML模块的gdxVersion和gwtVersion,但新增了GWT version is < 2.5 -> additional dependencies are not added提示,不清楚2.5版本来源
  • 搜索到的解决方案多针对Android Studio,与HTML构建无关
  • 创建全新libGDX项目,移除mavenLocal()仓库后仍出现相同错误

解决步骤

  1. 修正GWT版本配置:
    libGDX 1.11.0对应的GWT版本是2.9.0,而非1.11.0。在html/build.gradle中修改:

    gwt {
        gwtVersion = '2.9.0'
        // 保留其他原有配置
    }
    

    同时在根目录build.gradle的ext块中新增gwtVersion变量,统一管理:

    ext {
        // 原有变量...
        gwtVersion = '2.9.0'
    }
    

    然后在html/build.gradle中引用该变量:gwtVersion = rootProject.ext.gwtVersion

  2. 适配Gradle版本与插件兼容性:
    当前使用的org.wisepersist:gwt-gradle-plugin:1.1.19兼容Gradle 6.x-7.x,若你升级到了Gradle 8.x,需将插件版本升级到1.1.20+,同时org.gretty:gretty需升级到**4.0.0+**以适配Gradle 8。

  3. 清理并重新构建:
    执行以下命令清理缓存并重新构建:

    ./gradlew clean
    ./gradlew html:superDev
    
  4. 检查依赖冲突:
    若仍有问题,运行./gradlew html:dependencies查看GWT相关依赖的版本,确保没有旧版本的GWT依赖被引入,如有冲突可通过exclude排除:

    dependencies {
        implementation("com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion") {
            exclude group: 'com.google.gwt'
        }
        implementation "com.google.gwt:gwt-user:$gwtVersion"
        implementation "com.google.gwt:gwt-dev:$gwtVersion"
    }
    

内容的提问来源于stack exchange,提问作者Noah Crosby

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 00:04:57