【问题标题】:GWT HTML export from LibGdx shows : GwtApplication: exception: (TypeError)从 LibGdx 导出的 GWT HTML 显示:GwtApplication:异常:(TypeError)
【发布时间】:2018-12-10 12:38:41
【问题描述】:

我有一个使用 LibGdx 版本 1.9.9 开发的 Android 游戏,我正在尝试以 HTML 格式导出。我正在使用 GWT (V-2.8.2)。游戏在安卓上运行良好,没有任何问题。通过运行此命令./gradlew html:dist 导出游戏时,我没有收到任何错误。

但是当我将导出的库放入 localhost 并尝试访问游戏时,首先出现默认加载器,然后出现带有此错误消息的空白屏幕:

GwtApplication: exception: (TypeError) : null is not an object (evaluating 'null.zY') (TypeError) : null is not an object (evaluating 'null.zY')

这在每个浏览器中都会发生 - Safari、Chrome、Firefox。

堆栈跟踪没有显示任何重要的调试位置。

知道问题出在哪里吗?谢谢。

HTML Gradle:

gwt {
    gwtVersion='2.8.0' // Should match the gwt version used for building the gwt backend
    maxHeapSize="2G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY
    minHeapSize="1G"

    src = files(file("src/")) // Needs to be in front of "modules" below.
    modules 'com.package.gamename.GdxDefinition'
    devModules 'com.package.gamename.GdxDefinitionSuperdev'
    project.webAppDirName = 'webapp'

    compiler {
        strict = true;
        disableCastChecking = true;
    }
}

import org.wisepersist.gradle.plugins.gwt.GwtSuperDev

def HttpFileServer server = null
def httpFilePort = 8080

task startHttpServer () {
    dependsOn draftCompileGwt

    String output = project.buildDir.path + "/gwt/draftOut"

    doLast {
        copy {
            from "webapp"
            into output
        }

        copy {
            from "war"
            into output
        }

        server = new SimpleHttpFileServerFactory().start(new File(output), httpFilePort)

        println "Server started in directory " + server.getContentRoot() + ", http://localhost:" + server.getPort()
    }
}

task superDev (type: GwtSuperDev) {
    dependsOn startHttpServer
    doFirst {
        gwt.modules = gwt.devModules
    }
}


task dist(dependsOn: [clean, compileGwt]) {
    doLast {
        file("build/dist").mkdirs()
        copy {
            from "build/gwt/out"
            into "build/dist"
        }
        copy {
            from "webapp"
            into "build/dist"
            }
        copy {
            from "war"
            into "build/dist"
        }
    }
}

task addSource {
    doLast {
        sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
    }
}

tasks.compileGwt.dependsOn(addSource)
tasks.draftCompileGwt.dependsOn(addSource)

sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]


eclipse.project {
    name = appName + "-html"
}

【问题讨论】:

    标签: html gwt libgdx


    【解决方案1】:

    进入superdev模式,激活源码映射和调试,在Chrome中单步调试源码,这样才能发现这些问题。

    • 以 superdev 参数开头
    • 打开游戏网页
    • 点击左上角的箭头按钮
    • 点击“编译”按钮
    • 现在可以在 Chrome 中使用源映射,您可以获得“真实的”堆栈跟踪。

    【讨论】:

      猜你喜欢
      • 2018-11-22
      • 1970-01-01
      • 2017-05-30
      • 2014-04-20
      • 2021-10-31
      • 1970-01-01
      • 2016-05-06
      • 1970-01-01
      相关资源
      最近更新 更多