Change in GWT/HTML5 Libgdx Asset Mechanism

So far one had to copy over all the assets to the GWT project’s war/ folder and right a file called assets.txt manually. No longer. Through the magic of GWT Generators this is done automatically for you now. Here’s what you need to change:

In your GWT project’s module file (gwt.xml), add the following line:

That’s it. You can remove your assets.txt and the assets themselves from the war/ folder, the generator will copy them over everytime you launch or compile your HTML5 app. The path you specify can be absolute (bad if you share your project with other people) or relative to the GWT project’s root folder (e.g. “../superjumper-android/assets” for the superjumper-gwt project). The generator will output a ton of debugging messages, detailing what is going on.

The classification of assets into images, audio, text and binary files is done via an AssetFilter. If you do not specify your own, the DefaultAssetFilter is used. It’s pretty basic and might not fit your needs. If you want to overwrite that, implement the AssetFilter interface, make sure you have a public default constructor and that the class is accessible in your GWT project. Then add the following line to you GWT project’ module file:

The filter will then be instantiated by the generator and decide which files/directories to include and what AssetType they should have.

All demos and tests have been updated to use this mechanism, if in doubt, check those out.

5 thoughts on “Change in GWT/HTML5 Libgdx Asset Mechanism

  1. If you use the current setup utility (gdx-setup-ui.jar) to generate a set of projects, the MyProject-html project crashes when you try to run it as a “Web Application” through Eclipse with:

    java.lang.NullPointerException: null
    at Source)
    at com.badlogic.gdx.backends.gwt.preloader.FileWrapper.(
    at com.badlogic.gdx.backends.gwt.preloader.PreloaderBundleGenerator.generate(

    To resolve this, you have to go to the MAIN “MyProject” and edit MyProject.gwt.xml (it’s not just called “gwt.xml”) with the asset path as in this post, and then you should be able to run the MyProject-html project as a web application or “Google->GWT Compile” it. I imagine this qualifies as a bug in the setup utility, but this should at least help anyone who gets confused by the problem in the meantime.

  2. I know this is an old post but I’m having the same problem. I have a g3db model that shows perfecly fine in android and in desktop but the html5 version keeps saying the path does not exist, even though I can access the file itself in the jetty version gradle uses for the hosting.
    Has anyone solved this issue? Thanks!

Leave a Reply

Your email address will not be published.