从LibGdx导出的GWT HTML显示:GwtApplication:异常:(TypeError)

时间:2018-12-10 12:38:42

标签: html gwt libgdx

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

但是,当我将导出的库放入本地主机并尝试访问游戏时,首先会出现默认加载程序,然后出现空白屏幕并显示以下错误消息:

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"
}

Error Here is the error screenshot

1 个答案:

答案 0 :(得分:2)

进入superdev模式并激活源映射和调试,并逐步在Chrome中浏览源,这就是发现这些问题的方法。

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